2017-11-17 14 views
0

私の現在の場所をサイトからアクセスできるようにするには、そのポップアップの許可ボタンをクリックし、62.0、クロムドライババージョンを3.6.0と私は16.04のUbuntuを使用していますし、私のコードスニペットは、セレンテストケースでジオロケーションを有効または無効にする方法

ChromeOptions options = new ChromeOptions(); 
options.addArguments("--incognito"); 
options.addArguments("start-maximized"); 
options.addArguments("--disable-geolocation"); 
DesiredCapabilities capabilities=DesiredCapabilities.chrome(); 
capabilities.setCapability(ChromeOptions.CAPABILITY,options); 
driver = new ChromeDriver(capabilities); 

である。しかし、誰もが私は、このための完全なソリューションを提案することができ、これは、動作していませんか?必要に応じて、このため

+1

[mozillaとchromeブラウザでジオロケーションポップアップを処理するにはどうすればよいですか?](https://stackoverflow.com/questions/44321401/how-can-i-handle-geo-location-popup)ブラウザーを使用している - Mozillaとクロムのブラウザ) – DebanjanB

答えて

1
Robot r = new Robot(); 
r.keyPress(KeyEvent.VK_TAB); 
r.keyRelease(KeyEvent.VK_TAB); 
r.keyPress(KeyEvent.VK_TAB); 
r.keyRelease(KeyEvent.VK_TAB); 
r.keyPress(KeyEvent.VK_ENTER); 
r.keyRelease(KeyEvent.VK_ENTER); 

使用java.awt.Robotクラス、最初のテストは手動で、その後、あなたはキーハンドラを変更することができます。

関連する問題