2

I am trying to change the locale of my Chrome Webdriver I use in my Geb tests. My Chrome is normally running using a en locale. For some tests I need to request a german version of a website.

Here is what I did in my GebConfig.groovy.

//GebConfig.groovy

driver = {
   ChromeOptions options = new ChromeOptions()
   options.addArguments("--lang=de")
   options.addArguments("--start-maximized")
   new ChromeDriver(options)
}

The option --lang=de does not seem to affect the chrome during the test, since the website still responds with english content.

Am I missing something?

saw303
  • 8,051
  • 7
  • 50
  • 90
  • I also had same problem. Fortunately, in my website I have a possibility to append locale like url?locale=de – Knu8 Nov 03 '16 at 15:49
  • I am testing a single page application that uses a REST API. Introducing a locale parameter is of course technically possible but it would actually break our REST contract. I'd love to read the read the locale from the HTTP header instead in the HTTP query string. – saw303 Nov 03 '16 at 15:52
  • Is [this](https://stackoverflow.com/questions/20808209/how-to-set-browser-language-using-remotewebdriver) of any help – Knu8 Nov 03 '16 at 15:58
  • Setting only `options.addArguments("--lang=de")` does not affect Chrome. It still uses the system `en` locale – saw303 Nov 03 '16 at 16:25
  • As you noted, it will use the system locale. We had to setup a VM specifically for foreign language testing and update the display language via the Region and Language dialog. – jibbs Nov 03 '16 at 20:21
  • Thank you for your quick response @jibbs. You might want to convert your comment into a answer? – saw303 Nov 03 '16 at 20:23
  • Done. Glad I could save you the time of banging your head on this one. We did plenty of that! – jibbs Nov 03 '16 at 20:32

1 Answers1

3

As you noted in a comment above, it will use the system locale. We struggled with this same problem and ended up having to setup a VM specifically for foreign language testing and update the display language via the Region and Language dialog (Control Panel-> Region and Language-> Keyboards and Languages.)

We found all of the language packs we needed here: http://winaero.com/blog/download-official-mui-language-packs-for-windows-8-1-windows-8-and-windows-7/

jibbs
  • 742
  • 1
  • 8
  • 17