【发布时间】:2011-11-05 06:18:20
【问题描述】:
我正在使用 WebDriver 来测试我的应用程序,但有些页面正试图从另一台服务器获取资源,这需要身份验证。我的测试不需要这些资源,而且我没有凭据。 当弹出窗口出现时,它会停止测试运行。
我尝试使用webDriver.switchTo().alert().dismiss(); 关闭弹出窗口,但显然它没有提醒。
我还尝试使用 firefox 配置文件禁用弹出窗口:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("capability.policy.policynames", "strict") ;
profile.setPreference("capability.policy.strict.sites", "http://localhost:9000") ;
profile.setPreference("capability.policy.strict.Window.alert", "noAccess") ;
profile.setPreference("capability.policy.strict.Window.confirm", "noAccess") ;
profile.setPreference("capability.policy.strict.Window.prompt", "noAccess") ;
FirefoxDriver driver = new FirefoxDriver(profile);
但它没有帮助。
提前致谢。
【问题讨论】:
标签: java integration-testing webdriver selenium-webdriver