How do I enable geolocation support in chromedriver?

前端 未结 7 618
日久生厌
日久生厌 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:35

    Here is how I did it with capybara for cucumber tests

    Capybara.register_driver :selenium2 do |app|      
      profile = Selenium::WebDriver::Chrome::Profile.new
      profile['geolocation.default_content_setting'] = 1
    
      config = { :browser => :chrome, :profile => profile }    
      Capybara::Selenium::Driver.new(app, config)
    end
    

    And there is link to other usefull profile settings: pref_names.cc

    Take a look at "Tweaking profile preferences" in RubyBindings

提交回复
热议问题