0

I'm running a Selenium webdriver test in FireFox. After clicking on a button a Javascript (JQuery/Bootstrap) alert has to appear but no matter how I run the program (eclipse, debug mode, executable Jar) this alert never appears.

When executing exactly the same action by hand the alert appears always, even when I used the same browser session that was started up by the Selenium webdriver test. I'm using Selenium Webdriver 2.53 Java 1.7 Firefox 46.0.1 under Windows 10.

Anybody an idea why this alert doesn't appear

1
  • Recently I figured out that the waiting time of 10 seconds in my testprogram was not enough. After waiting for about 15 seconds the alertbox finally sppears. Curious because when testing manually it only takes two or Three seconds before the alertbox appears. Commented Jun 2, 2016 at 9:00

1 Answer 1

2

Actually in Selenium webdriver for Firefox by default the alert box is dismissed if it is appear.

So modify your DesiredCapabilities before initializing WebDriver to ignore this behavior by setting as follows :-

 DesiredCapabilities capabilities = DesiredCapabilities.firefox() capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,"ignore"); 

Hope this will help you..

Sign up to request clarification or add additional context in comments.

2 Comments

Saurabh, thank you for your answer. I added the code just before creating the WebDriver instance. Unfortunatly the alert box not appears, In the trace I see this line: Capabilities [ handlesAlerts=true], This seems to be telling me that Alerts has to appear, am I right?
No, it just read only capability, it just ensure Whether the session can interact with modal popups, such as window.alert and window.confirm

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.