Selenium Webdriver - set preferred browser language DE

前端 未结 4 1419
一生所求
一生所求 2021-01-21 19:45

I have a problem setting the preferred (accepted language) within headless Chrome using Selenium Webdriver and Ruby. I use the following WebDriver settings:

Sele         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 20:45

    I'am using this in my test_helper.rb Works fine for me.

    Capybara.register_driver :selenium do |app|
      Chromedriver.set_version "2.36"
    
      desired_capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
        'chromeOptions' => {
          'prefs' => {
            'intl.accept_languages' => 'en-US'
         },
         args: ['disable-gpu', 'headless']
       }
      )
    
      Capybara::Selenium::Driver.new(app, { browser: :chrome, desired_capabilities: desired_capabilities })
    end
    
    Capybara.javascript_driver = :chrome
    Capybara.default_driver = :selenium
    

提交回复
热议问题