Warning handling in webdriver 2.21 and mozilla11

I am using Firefox 11 + WebDriver 2.21.0 / WebDriver 2.22.0 (tried both).

In my scenario, when I click on a tab, it opens a confirmation window and when you click OK starts downloading a new tab from the server.

So, I view this scenario as:

 driver.findElement(By.id("myTab")).click(); driver.switchTo().alert().accept(); 

but after he clicks on "mytab", he waits for the window to load indefinitely. This way it does not alert.accept() , and the browser waits to confirm the confirmation dialog to load a new page, so I got into a deadlock state.

This code works well in Internet Explorer.

Please help, how to deal with the situation?

+1
java mozilla webdriver alert
source share
1 answer

You, sir, might find a mistake (or at least inconsistency) in Selenium WebDriver.

Look here if it was found earlier, and if there is no such error, feel free to write it down .

At the same time, you can try loading FirefoxDriver using an unstable download strategy , and then (if this is not enough) driver.manage().timeouts().pageLoadTimeout() possible (which works only for Firefox with the setting "unstable").

As a workaround, you can try clicking the tab using JavaScript - although I'm not sure if this will work or not work:

 ((JavascriptExecutor)driver).executeScript("document.getElementById('myTab').click()"); 

affairs>


Edit:

What could you do as another workaround (inspired by Selenium RC), you can temporarily turn off confirmation dialogs ...

 // assuming your driver can handle JS ;) JavascriptExecutor js = (JavascriptExecutor)driver; // stores the original confirm() function and replaces it js.executeScript("window.originalConfirm = window.confirm;" + "window.confirm = function(m) { return true; };"); driver.findElement(By.id("myTab")).click(); // it should not even fire the confirm and just proceed // get the confirm back js.executeScript("window.confirm = window.originalConfirm;"); 
0
source share

All Articles