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

Nightwatch V2.0 - Chrome crashes after URL command #2951

Closed piekutlukasz closed 2 years ago

piekutlukasz commented 2 years ago

Describe the bug

Issue refers to v2.0, on v.1.7.8 works fine. First thing what i'm surprised is case which chrome browser is running in GUI window and CLI at the same time. CLI is empty, without any output. After perform URL command chrome crashing/closing.

Verbose output

debug.log

```txt - Starting ChromeDriver on port 9515... \ Starting ChromeDriver on port 9515... Request POST /session { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { w3c: false, args: [] }, name: 'personal Area Data\\personal Data\\login\\show Login' }, capabilities: { alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': { w3c: false, args: [] } } } | Starting ChromeDriver on port 9515... Response 200 POST /session (2379ms) { sessionId: '96e31ede0e87f1d7683fa447e41bc9f0', status: 0, value: { acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: 'chrome', chrome: { chromedriverVersion: '95.0.4638.69 (6a1600ed572fedecd573b6c2b90a22fe6392a410-refs/branch-heads/4638@{#984})', userDataDir: 'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\scoped_dir12044_473160626' }, cssSelectorsEnabled: true, databaseEnabled: false, 'goog:chromeOptions': { debuggerAddress: 'localhost:55876' }, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: 'normal', platform: 'Windows', proxy: {}, rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, unexpectedAlertBehaviour: 'ignore', version: '95.0.4638.69', webStorageEnabled: true, 'webauthn:extension:credBlob': true, 'webauthn:extension:largeBlob': true, 'webauthn:virtualAuthenticators': true } i Connected to ChromeDriver on port 9515 (2557ms). Using: chrome (95.0.4638.69) on WINDOWS. Received session with ID: 96e31ede0e87f1d7683fa447e41bc9f0 → Running [before]: → Completed [before]. Running Show login on personal data preview screen: ─────────────────────────────────────────────────────────────────────────────────────────────────── → Running [beforeEach]: → Completed [beforeEach]. → Running command: perform ([Function]) Step ==> Login as: XXXXX using password: YYYYYYY → Completed command: perform ([Function]) (2ms) → Running command: Url ('#login') → Running command: perform ([Function]) Step ==> Go to url: http://10.86.216.234:5700/#login → Completed command: perform ([Function]) (1ms) → Running command: url ('http://10.86.216.234:5700/#login') Request POST /session/96e31ede0e87f1d7683fa447e41bc9f0/url { url: 'http://10.86.216.234:5700/#login' } Response 200 POST /session/96e31ede0e87f1d7683fa447e41bc9f0/url (2782ms) { sessionId: '96e31ede0e87f1d7683fa447e41bc9f0', status: 13, value: { message: 'unknown error: session deleted because of page crash\n' + 'from unknown error: cannot determine loading status\n' + 'from tab crashed\n' + ' (Session info: chrome=95.0.4638.69)\n' + ' (Driver info: chromedriver=95.0.4638.69 (6a1600ed572fedecd573b6c2b90a22fe6392a410-refs/branch-heads/4638@{#984}),platform=Windows NT 10.0.19042 x86_64)' } } → Completed command: url ('http://10.86.216.234:5700/#login') (2786ms) ```

When I add --no-sandbox parameter, chrome running at the same time 18 instances, but test running only in one of them. In one of CLI's i got output like this:

Chrome CLI '--no-sandbox' output

CLI.log

```txt [16564:13596:1118/104403.967:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 104 to 127 [16564:13596:1118/104403.967:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 106 to 125 [16564:13596:1118/104403.970:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 110 to 124 [16564:13596:1118/104403.970:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 112 to 123 [16564:13596:1118/104403.970:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 102 to 122 [16564:13596:1118/104403.970:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 103 to 121 [16564:13596:1118/104403.971:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 105 to 120 [16564:13596:1118/104403.971:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 111 to 119 [16564:13596:1118/104403.971:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 113 to 118 [16564:13596:1118/104405.142:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 104 to 127 [16564:13596:1118/104405.142:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 106 to 125 [16564:13596:1118/104405.142:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 110 to 124 [16564:13596:1118/104405.143:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 112 to 123 [16564:13596:1118/104405.143:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 102 to 122 [16564:13596:1118/104405.144:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 103 to 121 [16564:13596:1118/104405.144:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 105 to 120 [16564:13596:1118/104405.144:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 111 to 119 [16564:13596:1118/104405.144:WARNING:used_ids.h(55)] Duplicate id found. Reassigning from 113 to 118 [16564:13596:1118/104418.141:WARNING:webrtc_voice_engine.cc(698)] Attempting to stop aecdump when no audio processing module is present ```

When i use selenium server to run chromedriver browser starts correctly.

selenium server output

selenium server.log

```txt C:\Users\USERNAME\Projects\my_project>nightwatch C:\Users\USERNAME\Projects\my_project\tests\spec\ming\personalArea_data\personalData\login\showLogin.js --verbose --env selenium.chrome Tests are running using driver from path: C:\Users\USERNAME\Projects\my_project\node_modules\selenium-server\lib\runner\selenium-server-standalone-3.141.59.jar Socket for tagger watcher started on port: 5702 HTTPS Server is running on port: 5701 HTTP Server is running on port: 5700 [Ming\personal Area Data\personal Data\login\show Login] Test Suite ─────────────────────────────────────────────────────────────────────────────── - Starting Selenium Server on port 4444... Starting Selenium Server on port 4444... An error occurred while trying to start Selenium Server: cannot resolve path: "cat". Please check that the "webdriver.server_path" config property is set correctly. Selenium Server process closed. Cannot write log file to C:\Users\USERNAME\Projects\my_project\ming\personalArea_data\personalData\login\showLogin_selenium-server.log. Error: ENOENT: no such file or directory, open 'C:\Users\USERNAME\Projects\my_project\ming\personalArea_data\personalData\login\showLogin_selenium-server.log' | Starting Selenium Server on port 4444... Request POST /wd/hub/session { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { w3c: false, args: [] }, chromeOptions: { w3c: false }, name: 'personal Area Data\\personal Data\\login\\show Login' }, capabilities: { alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': { w3c: false, args: [] } } } | Starting Selenium Server on port 4444... Response 200 POST /wd/hub/session (4662ms) { status: 0, sessionId: 'ef9d656be6d7de30ab8744d22f81b1bc', value: { acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: 'chrome', chrome: { chromedriverVersion: '95.0.4638.69 (6a1600ed572fedecd573b6c2b90a22fe6392a410-refs/branch-heads/4638@{#984})', userDataDir: 'C:\\Users\\USERNAME\\AppData\\Local\\Temp\\scoped_dir21360_1492922860' }, cssSelectorsEnabled: true, databaseEnabled: false, 'goog:chromeOptions': { debuggerAddress: 'localhost:52137' }, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: 'normal', platform: 'Windows', proxy: {}, rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, unexpectedAlertBehaviour: 'ignore', version: '95.0.4638.69', webStorageEnabled: true, 'webauthn:extension:credBlob': true, 'webauthn:extension:largeBlob': true, 'webauthn:virtualAuthenticators': true, 'webdriver.remote.sessionid': 'ef9d656be6d7de30ab8744d22f81b1bc' } i Connected to Selenium Server on port 4444 (6130ms). Using: chrome (95.0.4638.69) on WINDOWS. Received session with ID: ef9d656be6d7de30ab8744d22f81b1bc → Running [before]: → Completed [before]. Running Show login on personal data preview screen: ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────── → Running [beforeEach]: → Completed [beforeEach]. → Running command: perform ([Function]) Step ==> Login to MojeING as: XXXXXX using password: YYYYYYYYYYY → Completed command: perform ([Function]) (2ms) → Running command: Url ('#login') → Running command: perform ([Function]) Step ==> Go to url: http://10.86.216.227:5700/#login → Completed command: perform ([Function]) (1ms) → Running command: url ('http://10.86.216.227:5700/#login') Request POST /wd/hub/session/ef9d656be6d7de30ab8744d22f81b1bc/url { url: 'http://10.86.216.227:5700/#login' } Response 200 POST /wd/hub/session/ef9d656be6d7de30ab8744d22f81b1bc/url (3235ms) { sessionId: 'ef9d656be6d7de30ab8744d22f81b1bc', status: 0, value: null } → Completed command: url ('http://10.86.216.227:5700/#login') (3239ms) → Completed command: Url ('#login') (3251ms) ```

Configuration

nightwatch.json

```js const minimist = require('minimist') const argv = minimist(process.argv) const workersNum = argv.workers const path = require('path') // Autogenerated by Nightwatch // Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/ const Services = {}; loadServices() module.exports = { detailed_output: true, live_output: false, test_workers: { enabled: false, workers: workersNum || 'auto' }, // 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/spec'], output_folder: 'tests/reports', // 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 globals_path: 'tests/globals.js', webdriver: {}, test_settings: { // ============================================================ default env =============================================== default: { globals: { environment: 'mock', configurationFilesLocation: './configuration/mock-default/', wcagOnClick: false, step: 1, serverPorts: { port: 5700, sslPort: 5701, watcherPort: 5702 } }, disable_error_log: false, screenshots: { enabled: true, path: 'tests/screenshots/mock/', on_failure: true, on_error: true }, desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ w3c: false, args: [ // '--no-sandbox', // '--ignore-certificate-errors', // '--allow-insecure-localhost', // '--headless' ] } }, webdriver: { start_process: true, port: 9515, server_path: (Services.chromedriver ? Services.chromedriver.path : process.env.CHROMEWEBDRIVER + '\\chromedriver.exe'), cli_args: [ '--verbose' ] } }, [...] // ============================================================== via selenium server ============================================= /// /////////////////////////////////////////////////////////////////////////////// // 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.path), cli_args: { 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : process.env.GECKOWEBDRIVER + '\\geckodriver.exe'), 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : process.env.CHROMEWEBDRIVER + '\\chromedriver.exe'), 'webdriver.edge.driver': (process.env.EDGEWEBDRIVER + '\\msedgedriver.exe') } } }, 'selenium.chrome': { extends: 'selenium_server', desiredCapabilities: { browserName: 'chrome', chromeOptions: { w3c: false } } } } } 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
npm --version 8.1.0
yarn --version -
node --version v16.13.0
Browser driver Version
chromedriver 95
selenium-webdriver v4.0.0
selenium-server 3.141.59
OS Version
Windows 10 -
piekutlukasz commented 2 years ago

I'll face the problem again. After update nightwatch to version 2.0.10 I'm trying run example scenario (ecosia). Test looking fine but I've get still runned CLI chrome windows besides GUI browser. It's intentional behaviour?

mil7 commented 2 years ago

I stumble over the same issue. Sound quite similar to this observation: https://svdoscience.com/2021-03-17/fix-session-deleted-page-crash-selenium-grid-chrome-docker

gravityvi commented 2 years ago

can you try using w3c:true in nightwatch config?

AutomatedTester commented 2 years ago

Closing as needed info hasn't been added