简体   繁体   中英

When running Selenium Webdriver Test no Alert appears

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

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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM