Search code examples
configurationinternationalizatione2e-testingcypresslang

How to set the browser's language in Cypress.io (electron/chrome)?


My question is about configuring Cypress to launch a browser instance in a certain language.

In order to:

  • make assertions on localized (i18n) text labels?
  • check i18n features (switching between languages)
  • bypass issues of Continuous Integration (CI/CD) when, for example, on a local computer, the browser default to fr_FR, and on the CI/CD VM it defaults to en_US?

I tried (without much success):


Solution

  • from Gleb Bahmutov:

    you set it during cy.visit using onBeforeLoad with something like Object.defineProperty(navigator, 'language', { value: 'de-GE' })

    src: https://gitter.im/cypress-io/cypress?at=5d61408a07d1ff39f8769545