Set the accept-language of Chrome in selenium tests

You can set the resolution and user agent used in selenium tests with chrome with the method described in this card, but you can also set the accept-language and other profile settings Show archive.org snapshot if you do this:

# features/support/chrome.rb
require "selenium/webdriver"


Capybara.register_driver :chrome320x480 do |app|
  args = []
  args << "--window-size=320,480"
  
  profile = Selenium::WebDriver::Chrome::Profile.new
  profile["intl.accept_languages"] = "en"
  
  Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args, :profile => profile)
end

This does not just apply for Chrome, it also works for other browsers such as Firefox.
You might have to find out about other key value pairs. For firefox there is a list here Show archive.org snapshot .
Anyway, the following setting is the same for firefox:

profile = Selenium::WebDriver::Firefox::Profile.new
profile["intl.accept_languages"] =  "de-DE"
Capybara::Selenium::Driver.new(app, :browser => :firefox, :args => args, :profile => profile)
Christoph Beck About 12 years ago