title: Selenium Webdriver - set preferred browser language DE
body: <p>I have a problem setting the preferred (accepted language) within headless Chrome using Selenium Webdriver and Ruby. I use the following WebDriver settings:</p>
  
  <pre><code>Selenium::WebDriver::Chrome.driver_path = @config[&lt;path to the Chrome Driver&gt;]
  
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument('--headless')
  options.add_argument('--disable-translate')
  options.add_argument("--lang=de")
  </code></pre>
  
  <p>The driver is then initialized with:</p>
  
  <pre><code>@selenium_driver = Selenium::WebDriver.for :chrome, options: options
  </code></pre>
  
  <p>Everything works fine but at some pages Chrome returns English content even when I navigate to the German page URL (e.g. page.de). In these cases the Chrome driver returns the English content due to an internal forwarding to page.de/en. I do not specify the en path in my queried URL.</p>
  
  <p>I have tried to set the language using the Webdriver preference:</p>
  
  <pre><code>options.add_preference('accept_languages', 'de')
  </code></pre>
  
  <p>instead of the add_argument but it doesn't change anything of the behavior.</p>
  
  <p>Does anyone have an idea how to force a headless Chrome controlled by Selenium Webdriver within Ruby to request page content in a defined language or - not optimal but it might help as a workaround - to stop the forwarding?</p>
  
  <p>Any help greatly appreciated</p>
  
  <p>Best </p>
  
  <p>Krid</p>