当使用selenium在chrome浏览器中启动web应用程序时,Geo-location(Geo Location) Pop就会出现在浏览器的顶部。
因此,我的一些基于位置的测试用例失败了。
如何使用色度驱动器处理此类场景?
发布于 2016-03-16 08:44:58
"When ever launching the web-app in chrome browser using selenium webdriver,
Geo-location(Geo Location) Pop up is coming on the top of the browser."在这种情况下,你可以尝试这样的方法:
@BeforeMethod
public void clearPopup() {
driver.navigate().refresh();
Thread.sleep(2000);//wait until the page is loaded.
//try to use explicit wait
try {
Alert alert = driver.switchTo().alert();
alert.dismiss();
} catch (NoAlertPresentException ex) {
//System.out.println("No alert for this test case.");
}
}此方法将在所有您的测试用例之前运行,如果有任何弹出显示,它将解除警报。
我也查过你的网址了。当我单击call geolocation时,会显示一个pop。你可以通过做以下几件事情来阻止这种弹出:
-go to settings of chrome and click on advanced settings.
-than click on content settings under privacy.
-than u will see pop ups and location options.在那里选择你想要的选项。选择
"Allow all sites to track ur physical location" 如果你不想看到弹出式的。
https://stackoverflow.com/questions/36029551
复制相似问题