Popup window blocks any further action by Selenium webdriver on IE

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Popup window blocks any further action by Selenium webdriver on IE



I am having pop-up window with "Ok/Cancel" using IE11. However, with selenium webdriver, I am unable perform anything on them. I have tried both: alert.accept() and switchto.window() without any success. I am unable to use dev tool on this popup as well. It wont allow me to do anything on the parent window. The keyboard "ENTER" and "ESC" works on this manually.


***Option1:***
try {
WebDriverWait wait = new WebDriverWait(myDriver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = myDriver.switchTo().alert();
alert.accept();

} catch (Exception e) {
//exception handling
}

***Option2:***
for(String winHandle : myDriver.getWindowHandles()){
if(!winHandle.equals(parentWindow)){
myDriver.switchTo().window(winHandle);
try {
WebDriverWait wait = new WebDriverWait(myDriver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = myDriver.switchTo().alert();
alert.accept();

} catch (Exception e) {
//exception handling
}
myDriver.switchTo().window(parentWindow);
((JavascriptExecutor) myDriver).executeScript("window.focus();");
}



Option3:


Robot robot = new Robot();
Thread.sleep(100);
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(100);
robot.keyRelease(KeyEvent.VK_ENTER);









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?