1

I have write a few browser test who run with TestCafe, chrome:headless. The test are launched by commandline, from a server that I don't want to change the default language.

My website is multi-language. I want to be change the language of the test, without having to impact the language of the server/computer each time. How can I do that?

I launch the tests with this command line:

npx testcafe chrome:headless src/scenarios/**/*.test.ts
Vladimir A.
  • 2,202
  • 2
  • 10
  • 28
sab
  • 4,352
  • 7
  • 36
  • 60

1 Answers1

1

It all depends on your "multi-language" implementation:

  1. Navigate to some "locale" page version (example.com/en/).
  2. Start your tests from a landing page and then navigate to the specific "locale" version:
await t
    .click(Selector('#choose-lang-combo')
    .click(Selector('#en-lang'))
  1. Try to add your own Accept-Language header to your request.
  2. Use a custom user profile. Maybe just using the --lang flag (testcafe chrome --lang=es) will help you (without the custom user profile):

For example, to create a shortcut that launches Google Chrome in Spanish (es), you might create a shortcut named chrome-es that has the following target:path_to_chrome.exe --lang=es --user-data-dir=c:\chrome-profile-es

Vladimir A.
  • 2,202
  • 2
  • 10
  • 28