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.79k stars 1.31k forks source link

Unable to get "start-maximized" setting to work on version 2.0.0-beta.1 #2952

Closed awulkan closed 2 years ago

awulkan commented 2 years ago

Describe the bug

Hey, I just installed Nightwatch 2.0.0-beta.1 in a clean project. However I'm unable to get the "start-maximized" config to work properly.

Steps to reproduce:

  1. Run npm init.
  2. Run npm i nightwatch@next.
  3. Run npm i chromedriver --save-dev.
  4. Add "start-maximized" as config value in args for Chrome (see config below).
  5. Run built-in test: npx nightwatch node_modules/nightwatch/examples/tests/ecosia.js

Result: Neither Firefox or Chrome starts in maximized mode.

Sample test

Run with command

$ npx nightwatch node_modules/nightwatch/examples/tests/ecosia.js

Verbose output

debug.log

```txt PS C:\Website\git\nightwatch-test> npx nightwatch node_modules/nightwatch/examples/tests/ecosia.js --verbose [Ecosia.org Demo] Test Suite ──────────────────────────────────────────────────────── ⠋ Starting ChromeDriver on port 9515... Starting ChromeDriver with server_path=C:\Website\git\nightwatch-test\node_modules\chromedriver\lib\chromedriver\chromedriver.exe... Request POST /session { desiredCapabilities: { browserName: 'chrome', name: 'Ecosia.org Demo', 'goog:chromeOptions': {} }, capabilities: { alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} } } ⠇ Starting ChromeDriver on port 9515... Response 200 POST /session (775ms) { value: { capabilities: { acceptInsecureCerts: false, browserName: 'chrome', browserVersion: '96.0.4664.45', chrome: { chromedriverVersion: '96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947})', userDataDir: 'C:\\Users\\USER~1\\AppData\\Local\\Temp\\scoped_dir6408_2007427460' }, 'goog:chromeOptions': { debuggerAddress: 'localhost:52591' }, networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'windows', 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: 'fde4964a16185b258a4d86d293bdcaf4' } ℹ Connected to ChromeDriver on port 9515 (849ms). Using: chrome (96.0.4664.45) on WINDOWS. Received session with ID: fde4964a16185b258a4d86d293bdcaf4 → Running [before]: → Running command: navigateTo ('https://www.ecosia.org/') Request POST /session/fde4964a16185b258a4d86d293bdcaf4/url { url: 'https://www.ecosia.org/' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/url (1381ms) { value: null } → Completed command: navigateTo ('https://www.ecosia.org/') (1386ms) → Completed [before]. Running Demo test ecosia.org: ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── → Running [beforeEach]: → Completed [beforeEach]. → Running command: waitForElementVisible ('body') Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: 'body' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (15ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'f675dc31-a0b0-41fc-8608-ffec47a8a8db' } ] } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync { script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)', args: [ { 'element-6066-11e4-a52e-4f735466cecf': 'f675dc31-a0b0-41fc-8608-ffec47a8a8db', ELEMENT: 'f675dc31-a0b0-41fc-8608-ffec47a8a8db' } ] } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync (16ms) { value: true } √ Element was visible after 39 milliseconds. → Completed command: waitForElementVisible ('body') (43ms) → Running command: assert.titleContains ('Ecosia') → Running command: title ([Function]) Request GET /session/fde4964a16185b258a4d86d293bdcaf4/title Response 200 GET /session/fde4964a16185b258a4d86d293bdcaf4/title (5ms) { value: 'Ecosia - the search engine that plants trees' } √ Testing if the page title contains 'Ecosia' (12ms) → Completed command: assert.titleContains ('Ecosia') (14ms) → Completed command: title ([Function]) (9ms) → Running command: assert.visible ('input[type=search]') → Running command: isVisible ({selector, suppressNotFoundErrors}, [Function]) Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: 'input[type=search]' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (15ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c' } ] } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync { script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)', args: [ { 'element-6066-11e4-a52e-4f735466cecf': 'e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c', ELEMENT: 'e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c' } ] } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync (17ms) { value: true } √ Testing if element is visible (44ms) → Completed command: assert.visible ('input[type=search]') (45ms) → Completed command: isVisible ({selector, suppressNotFoundErrors}, [Function]) (39ms) → Running command: setValue ('input[type=search]', 'nightwatch') Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: 'input[type=search]' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (8ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c' } ] } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/element/e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c/clear {} Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/element/e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c/clear (35ms) { value: null } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/element/e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c/value { text: 'nightwatch', value: [ 'n', 'i', 'g', 'h', 't', 'w', 'a', 't', 'c', 'h' ] } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/element/e5e6c97b-8ff3-4eb1-b099-a0a1cf96753c/value (84ms) { value: null } → Completed command: setValue ('input[type=search]', 'nightwatch') (133ms) → Running command: assert.visible ('button[type=submit]') → Running command: isVisible ({selector, suppressNotFoundErrors}, [Function]) Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: 'button[type=submit]' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (11ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': '0295d565-9c34-4f28-bfc3-f08977581a9c' } ] } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync { script: 'return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a... (44027 characters)', args: [ { 'element-6066-11e4-a52e-4f735466cecf': '0295d565-9c34-4f28-bfc3-f08977581a9c', ELEMENT: '0295d565-9c34-4f28-bfc3-f08977581a9c' } ] } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/execute/sync (15ms) { value: true } √ Testing if element is visible (31ms) → Completed command: assert.visible ('button[type=submit]') (32ms) → Completed command: isVisible ({selector, suppressNotFoundErrors}, [Function]) (31ms) → Running command: click ('button[type=submit]') Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: 'button[type=submit]' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (8ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': '0295d565-9c34-4f28-bfc3-f08977581a9c' } ] } Request POST /session/fde4964a16185b258a4d86d293bdcaf4/element/0295d565-9c34-4f28-bfc3-f08977581a9c/click {} Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/element/0295d565-9c34-4f28-bfc3-f08977581a9c/click (2016ms) { value: null } → Completed command: click ('button[type=submit]') (2035ms) → Running command: assert.containsText ('.mainline-results', 'Nightwatch.js') → Running command: getText ({selector, suppressNotFoundErrors}, [Function]) Request POST /session/fde4964a16185b258a4d86d293bdcaf4/elements { using: 'css selector', value: '.mainline-results' } Response 200 POST /session/fde4964a16185b258a4d86d293bdcaf4/elements (26ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': '216a4273-e5a9-491a-b048-b9ca38704eb6' } ] } Request GET /session/fde4964a16185b258a4d86d293bdcaf4/element/216a4273-e5a9-491a-b048-b9ca38704eb6/text Response 200 GET /session/fde4964a16185b258a4d86d293bdcaf4/element/216a4273-e5a9-491a-b048-b9ca38704eb6/text (160ms) { value: 'Nightwatch (1997) - IMDb\n' + 'https://www.imdb.com/title/tt0119791\n' + 'Nightwatch: Directed by Ole Bornedal. ...', suppressBase64Data: true } √ Testing if element <.mainline-results> contains text 'Nightwatch.js' (217ms) → Completed command: assert.containsText ('.mainline-results', 'Nightwatch.js') (219ms) → Completed command: getText ({selector, suppressNotFoundErrors}, [Function]) (191ms) → Running [afterEach]: → Completed [afterEach]. OK. 5 assertions passed. (2.531s) → Running [after]: → Running command: end () → Running command: session ('delete', [Function]) Request DELETE /session/fde4964a16185b258a4d86d293bdcaf4 Response 200 DELETE /session/fde4964a16185b258a4d86d293bdcaf4 (80ms) { value: null } → Completed command: end () (99ms) → Completed command: session ('delete', [Function]) (84ms) → Completed [after]. Wrote report file to: tests_output\CHROME_96.0.4664.45__ecosia.xml. ```

Configuration

nightwatch.conf.js

```js // Autogenerated by Nightwatch // Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/ const Services = {}; loadServices(); // _ _ _ _ _ _ _ // | \ | |(_) | | | | | | | | // | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ // | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ // | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | // \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| // __/ | // |___/ 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: [], // See https://nightwatchjs.org/guide/working-with-page-objects/ page_objects_path: ['node_modules/nightwatch/examples/pages/'], // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands custom_commands_path: ['node_modules/nightwatch/examples/custom-commands/'], // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions custom_assertions_path: '', // See https://nightwatchjs.org/guide/#external-globals globals_path : '', webdriver: {}, test_settings: { default: { disable_error_log: false, launch_url: 'https://nightwatchjs.org', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName : 'firefox' }, webdriver: { start_process: true, server_path: '' } }, firefox: { desiredCapabilities : { browserName : 'firefox', alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ] } } }, webdriver: { start_process: true, server_path: '', cli_args: [ // very verbose geckodriver logs // '-vv' ] } }, chrome: { desiredCapabilities : { browserName : 'chrome', 'goog:chromeOptions' : { w3c: true, args: [ "start-maximized", ] } }, webdriver: { start_process: true, server_path: '', cli_args: [ // --verbose ] } }, edge: { desiredCapabilities : { browserName : 'MicrosoftEdge', 'ms:edgeOptions' : { w3c: true, // 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 cucumber-js (https://cucumber.io) | // | // It uses the bundled examples inside the nightwatch examples folder; feel free | // to adapt this to your own project needs | ////////////////////////////////////////////////////////////////////////////////// 'cucumber-js': { src_folders: ['examples/cucumber-js/features/step_definitions'], test_runner: { // set cucumber as the runner type: 'cucumber', // define cucumber specific options options: { //set the feature path feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature', // start the webdriver session automatically (enabled by default) // auto_start_session: true // use parallel execution in Cucumber // parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2 } } }, ////////////////////////////////////////////////////////////////////////////////// // 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: true } } }, '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: true } } }, '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.0.0-beta.1 (local install)
npm --version 8.1.0
yarn --version VERSION
node --version 16.13.0
Browser driver Version
Chrome 96.0.4664.45
OS Version
Windows 10 21H1 - 19043.1348
harshit-bs commented 2 years ago

@awulkan This seems to be a chromedriver issue. I propose using --start-fullscreen or --kiosk instead of start-maximized because these arguments work for me.

args: [
  "--start-fullscreen"
]