How do I enable geolocation support in chromedriver?

前端 未结 7 603
日久生厌
日久生厌 2020-11-30 08:08

I need to test a JS geolocation functionality with Selenium and I am using chromedriver to run the test on the latest Chrome.

The problem is now that Chrome prompts

7条回答
  •  借酒劲吻你
    2020-11-30 08:44

    Approach which worked for me in Firefox was to visit that site manually first, give those permissions and afterwards copy firefox profile somewhere outside and create selenium firefox instance with that profile.

    So:

    1. cp -r ~/Library/Application\ Support/Firefox/Profiles/tp3khne7.default /tmp/ff.profile

    2. Creating FF instance:

      FirefoxProfile firefoxProfile = new FirefoxProfile(new File("/tmp/ff.profile"));
      FirefoxDriver driver = new FirefoxDriver(firefoxProfile);
      

    I'm pretty sure that something similar should be applicable to Chrome. Although api of profile loading is a bit different. You can check it here: http://code.google.com/p/selenium/wiki/ChromeDriver

提交回复
热议问题