Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plz add to docs - localization/ internationalization testing #2331

Closed
HansHammel opened this issue Apr 10, 2020 · 2 comments
Closed

plz add to docs - localization/ internationalization testing #2331

HansHammel opened this issue Apr 10, 2020 · 2 comments

Comments

@HansHammel
Copy link

Please add to docs.

Having a non-english desktop environment, we need to switch locales
e.g. for localization/ internationalization testing
solved by using Playwright's local option for switching languages within a new browser session

session(
  'emulate english browser',
  { /* Playwright specific option */ locale: 'en-US' },
  () => {...})

Sample:

// this works for Playwright only
Scenario(
  'use preferred browser language (navigator.locale) to rediect the url, en -> /',
  (I) => {
    // switch browser to english localizaton
    // set browser local to english see https://github.com/microsoft/playwright/blob/master/docs/api.md
    session(
      'english browser',
      { /* Playwright specific option */ locale: 'en-US' },
      () => {
        // in case language detection relies on the request header vs navigator.language(s)
        I.haveRequestHeaders(
          'Accept-Language',
          'en-US, de;q=0.9, fr;q=0.8, es;q=0.7, *;q=0.5'
        )
        I.amOnPage('/')
        I.see('English') // language picker shows english
        I.dontSeeInCurrentUrl('/de') // not redirected to german url
        I.dontSee('Deutsch') // language picker does not show german
      }
    )
  }
)
@DavertMik
Copy link
Contributor

Thanks, that seems like a good idea!

@DavertMik
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants