nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.78k stars 1.31k forks source link

intl.accept_languages is not honored #3245

Closed kmahata closed 2 years ago

kmahata commented 2 years ago

Describe the bug

Our website based on browser locale loads different country content. For V1 we used to pass
prefs: { 'profile.managed_default_content_settings.notifications': 1, 'intl.accept_languages': 'de-de', }, to load german content even on login page. We are trying to migrate to v2 and the same config doesnt work and still loads in english for all configs.Tried few other formats and nothing worked. This is a blocker as we support 17 different locales

Sample test

describe('i18n issue', ()=>{
    it('I18n', async (browser)=>{
        browser.url("https://my-int.norton.com/extspa/lifelock")
        browser.pause()

    })
})

BROWSER - chrome 102

// Please add the sample test here

Run with command

npx nightwatch tests/firstTest.js -e de  --config nightwatch.conf.js

### Verbose output
[i18n issue] Test Suite
──────────────────────────────────────────────
⠋ Starting ChromeDriver on port 9515...
 Starting ChromeDriver with server_path=/************/seleniumExp/node_modules/chromedriver/lib/chromedriver/chromedriver...
   Request POST /session  
   {
     desiredCapabilities: {
       browserName: 'chrome',
       chromeOptions: {
         prefs: {
           'profile.managed_default_content_settings.notifications': 1,
           'intl.accept_languages': 'de-de'
         }
       },
       name: 'i18n issue',
       'goog:chromeOptions': {}
     },
     capabilities: { alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} } }
⠧ Starting ChromeDriver on port 9515...
   Response 200 POST /session (5362ms)
   {
     value: {
       capabilities: {
         acceptInsecureCerts: false,
         browserName: 'chrome',
         browserVersion: '102.0.5005.115',
         chrome: {
           chromedriverVersion: '102.0.5005.61 (0e59bcc00cc4985ce39ad31c150065f159d95ad3-refs/branch-heads/5005@{#819})',
           userDataDir: '/var/folders/04/hfp8pt157rl8sqg9s9lhff3c0k1ts2/T/.com.google.Chrome.ghQsOE'
         },
         'goog:chromeOptions': { debuggerAddress: 'localhost:64617' },
         networkConnectionEnabled: false,
         pageLoadStrategy: 'normal',
         platformName: 'mac os x',
         proxy: {},
         setWindowRect: true,
         strictFileInteractability: false,
         timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
         unhandledPromptBehavior: 'dismiss and notify',
         'webauthn:extension:credBlob': true,
         'webauthn:extension:largeBlob': true,
         'webauthn:virtualAuthenticators': true
       },
       sessionId: 'db3f1b2a5f590d814c1d95435cb46d87'
     }
ℹ Connected to ChromeDriver on port 9515 (5440ms).
  Using: chrome (102.0.5005.115) on MAC OS X.

 Received session with ID: db3f1b2a5f590d814c1d95435cb46d87

 → Running [before]:
 → Completed [before].

  Running I18n:
────────────────────────────────────────────────────────────────────────────────────────────────────────────
 → Running [beforeEach]:
 → Completed [beforeEach].
 → Running [afterEach]:

 → Running command: url ('https://my-int.norton.com/extspa/lifelock')
  ⠋ Loading url: https://my-int.norton.com/extspa/lifelock
   Request POST /session/db3f1b2a5f590d814c1d95435cb46d87/url  
  ⠼ Loading url: https://my-int.norton.com/extspa/lifelock
   Response 200 POST /session/db3f1b2a5f590d814c1d95435cb46d87/url (15720ms)
  ℹ Loaded url https://my-int.norton.com/extspa/lifelock in 15722ms
  → Completed command: url ('https://my-int.norton.com/extspa/lifelock') (15722ms)

 → Running command: pause ()
Waiting... Press Ctrl+C to exit.
^C ChromeDriver process closed.

 → Running command: end ([Function])

 → Running command: session ('delete', [Function])
   Request DELETE /session/db3f1b2a5f590d814c1d95435cb46d87  

Configuration

nightwatch.json

```js // Autogenerated by Nightwatch // Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/ const Services = {}; loadServices(); module.exports = { // An array of folders (excluding subfolders) where your tests are located; // if this is not specified, the test source must be passed as the second argument to the test runner. src_folders: ["./tests"], // See https://nightwatchjs.org/guide/working-with-page-objects/ page_objects_path: '', // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands custom_commands_path: '', // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions custom_assertions_path: '', // See https://nightwatchjs.org/guide/#external-globals webdriver: {}, test_settings: { default: { disable_error_log: true, launch_url: 'https://my-int.norton.com/extspa/lifelock', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName : 'chrome' }, webdriver: { start_process: true, server_path: (Services.chromedriver ? Services.chromedriver.path : '') } }, de: { launch_url: 'https://my-int.norton.com/extspa/lifelockint', desiredCapabilities: { chromeOptions: { prefs: { 'profile.managed_default_content_settings.notifications': 1, 'intl.accept_languages': 'de-de', }, }, }, }, safari: { desiredCapabilities : { browserName : 'safari', alwaysMatch: { acceptInsecureCerts: false } }, webdriver: { port: 4445, start_process: true, server_path: '/usr/bin/safaridriver' } }, firefox: { desiredCapabilities : { browserName : 'firefox', alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ] } } }, webdriver: { start_process: true, port: 4444, server_path: (Services.geckodriver ? Services.geckodriver.path : ''), cli_args: [ // very verbose geckodriver logs // '-vv' ] } }, chrome: { desiredCapabilities : { browserName : 'chrome', 'goog:chromeOptions' : { // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ // // This tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78) w3c: true, args: [ //'--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', //'--headless' ] } }, webdriver: { start_process: true, port: 9515, server_path: (Services.chromedriver ? Services.chromedriver.path : ''), cli_args: [ // --verbose ] } }, edge: { desiredCapabilities : { browserName : 'MicrosoftEdge', 'ms:edgeOptions' : { w3c: false, // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options args: [ //'--headless' ] } }, webdriver: { start_process: true, // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ // and set the location below: server_path: '', cli_args: [ // --verbose ] } }, ////////////////////////////////////////////////////////////////////////////////// // Configuration for when using the browserstack.com cloud service | // | // Please set the username and access key by setting the environment variables: | // - BROWSERSTACK_USER | // - BROWSERSTACK_KEY | // .env files are supported | ////////////////////////////////////////////////////////////////////////////////// browserstack: { selenium: { host: 'hub-cloud.browserstack.com', port: 443 }, // More info on configuring capabilities can be found on: // https://www.browserstack.com/automate/capabilities?tag=selenium-4 desiredCapabilities: { 'bstack:options' : { userName: '${BROWSERSTACK_USER}', accessKey: '${BROWSERSTACK_KEY}', } }, disable_error_log: true, webdriver: { timeout_options: { timeout: 15000, retry_attempts: 3 }, keep_alive: true, start_process: false } }, 'browserstack.local': { extends: 'browserstack', desiredCapabilities: { 'browserstack.local': true } }, 'browserstack.chrome': { extends: 'browserstack', desiredCapabilities: { browserName: 'chrome', chromeOptions : { w3c: false } } }, 'browserstack.firefox': { extends: 'browserstack', desiredCapabilities: { browserName: 'firefox' } }, 'browserstack.ie': { extends: 'browserstack', desiredCapabilities: { browserName: 'internet explorer', browserVersion: '11.0' } }, 'browserstack.safari': { extends: 'browserstack', desiredCapabilities: { browserName: 'safari' } }, 'browserstack.local_chrome': { extends: 'browserstack.local', desiredCapabilities: { browserName: 'chrome' } }, 'browserstack.local_firefox': { extends: 'browserstack.local', desiredCapabilities: { browserName: 'firefox' } }, ////////////////////////////////////////////////////////////////////////////////// // Configuration for when using the Selenium service, either locally or remote, | // like Selenium Grid | ////////////////////////////////////////////////////////////////////////////////// selenium_server: { // Selenium Server is running locally and is managed by Nightwatch selenium: { start_process: true, port: 4444, server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''), cli_args: { 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''), 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '') } } }, 'selenium.chrome': { extends: 'selenium_server', desiredCapabilities: { browserName: 'chrome', chromeOptions : { w3c: false } } }, 'selenium.firefox': { extends: 'selenium_server', desiredCapabilities: { browserName: 'firefox', 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ] } } } } }; function loadServices() { try { Services.seleniumServer = require('selenium-server'); } catch (err) {} try { Services.chromedriver = require('chromedriver'); } catch (err) {} try { Services.geckodriver = require('geckodriver'); } catch (err) {} } ```

Your Environment

Executable Version
nightwatch --version 2.2.1
npm --version 6.13.6

| node --version | VERSION |

Browser driver Version
NAME VERSION
OS Version
NAME VERSION
beatfactor commented 2 years ago

which browser/version?

beatfactor commented 2 years ago

Never mind, I see it's Chrome. Can you please try the 2.2.3? We merged a fix for chromeOptions.

kmahata commented 2 years ago

@beatfactor - With latest build its fixed. closing it

kmahata commented 2 years ago

https://github.com/nightwatchjs/nightwatch/issues/3183 - fixes it