Home Ask Login Register

Developers Planet

Your answer is one click away!

Rijo Mon February 2016

how to handle org.openqa.selenium.UnhandledAlertException in selenium webdriver

I am getting this pop up while executing the script:

Modal dialog present: A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.

Can you please mention how to handle this by clicking continue button.Please find out the url below to see the screenshot http://i.stack.imgur.com/eXXFO.png


Sanjay Bhimani February 2016

It was because of default behavior of driver when it reaches to an alert. The default behavior - "ACCEPT", so alert was closed automatically. That's why switchTo().alert() couldn't find it.

At the time of creating desirecapabilities you can modify it.

DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
WebDriver driver = new FirefoxDriver(dc);

To handle,

// untill timeout
try {  
   Alert alt = driver.switchTo().alert();
} catch(NoAlertPresentException noe) {
   // no alert.

Sanchita February 2016

Try setting the following values in Firefox profile-

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("dom.max_chrome_script_run_time", 0);
profile.setPreference("dom.max_script_run_time",  0); 
WebDriver driver = new FirefoxDriver(profile);

Post Status

Asked in February 2016
Viewed 3,807 times
Voted 5
Answered 2 times


Leave an answer

Quote of the day: live life