2016-03-16 38 views
0

使用selenium webdriver在Chrome瀏覽器中啓動Web應用程序時,地理位置(地理位置)彈出窗口位於瀏覽器的頂部。如何處理使用Selenium chromedriver的地理位置彈出窗口?

由於我的一些基於位置的測試用例失敗。

如何使用chromedriver處理這些情況?

+0

可以請你分享一下HTML代碼..如果可能的話鏈接或者模擬器的例子..彈出窗口的圖片等..它會幫助我們更好地幫助你 –

+0

Eg.Link:www.mobile.Kohls.com,if你啓動這個電子商務網站。地理位置彈出窗口即將到來。如果您使用的是appium,則可以查看該 –

+0

,然後添加功能autoAcceptAlerts,true –

回答

0
"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." 
在這種情況下

,U可以嘗試這樣的事情:

@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."); 
      }   
} 

此方法將所有Ur測試用例之前運行,如果任何彈出窗口顯示它會解除警報。

我也有通過你的網址。當我點擊通話地理位置API時,會顯示一個彈出窗口。 U可以通過以下方式阻止這種彈出:

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

如果你不想看到彈出窗口。

相關問題