运行Selenium Webdriver Test时,没有出现警报 [英] When running Selenium Webdriver Test no Alert appears
问题描述
我正在FireFox中运行Selenium Webdriver测试.单击按钮后,必须出现Javascript(JQuery/Bootstrap)警报,但是无论我如何运行程序(Eclipse,调试模式,可执行Jar),该警报都不会出现.
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.
当手动执行完全相同的操作时,即使我使用的是由Selenium Webdriver测试启动的相同浏览器会话,也会始终显示警报.我正在Windows 10下使用Selenium Webdriver 2.53 Java 1.7 Firefox 46.0.1.
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
推荐答案
实际上,默认情况下,在Firefox的Selenium Webdriver中,如果显示警告框,则将其关闭.
Actually in Selenium webdriver for Firefox by default the alert box is dismissed if it is appear.
因此,在初始化WebDriver之前,请通过如下设置来修改DesiredCapabilities,以忽略此行为:-
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..
这篇关于运行Selenium Webdriver Test时,没有出现警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!