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.83k stars 1.32k forks source link

Ecosia.js test cannot run with existing nightwatch.conf.js on Nightwatch version 2.0.7 #3055

Closed chriscuba23 closed 2 years ago

chriscuba23 commented 2 years ago

Describe the bug

After upgrading from version 1.7.13 to 2.0.7 and without any change to my configuration file I tried to run the demo test that you have

Reproduce steps: upgrade to version 2.0.7, create an ecosia.js file and run it

Sample test

ecosia.js

```js // Please add the sample test here describe('Demo test Ecosia.org', function() { test('search for nightwatch', function(browser) { browser .url('https://www.ecosia.org/') .waitForElementVisible('body') .assert.titleContains('Ecosia') .assert.visible('input[type=search]') .sendKeys('input[type=search]', 'nightwatch') .assert.visible('button[type=submit]') .click('button[type=submit]') .assert.containsText('.mainline-results', 'Nightwatch.js') .end(); }) }); ```

Run with command

$ node nightwatch -e chrome ecosia.js --verbose

Verbose output

debug.log

```txt there is no log file produced. test does not even run ```

Configuration

nightwatch.conf.js

```js // Autogenerated by Nightwatch // Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/ const Services = {}; loadServices(); require('dotenv').config(); const FAILURES_ERRORS_PATH = "./failures"; // Location of the screenshots taken on failures/errors const REPORTS = "./reports"; // The location where the JUnit XML report files will be saved. 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: ["Scenarios"], // See https://nightwatchjs.org/guide/working-with-page-objects/ page_objects_path: "pages", // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands custom_commands_path: ["./custom_commands", "node_modules/nightwatch-custom-commands-assertions/js/commands", "node_modules/nightwatch-helpers/commands", "./node_modules/nightwatch-xhr/es5/commands", "./node_modules/nightwatch-mixpanel/es5/commands", "./node_modules/nightwatch-vrt/commands"], // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions custom_assertions_path: ["./custom_assertions", "node_modules/nightwatch-custom-commands-assertions/js/assertions", "node_modules/nightwatch-helpers/assertions", "./node_modules/nightwatch-xhr/es5/assertions", "./node_modules/nightwatch-mixpanel/es5/assertions", "node_modules/nightwatch-vrt/assertions"], // See https://nightwatchjs.org/guide/#external-globals globals_path: "./globals.js", data_path: "data", output_folder: REPORTS, // The location where the JUnit XML report files will be saved. live_output: false, // Whether or not to buffer the output in case of parallel running detailed_output: true, // By default detailed assertion output is displayed while the test is running. Set this to `false` if you'd like to only see the test case name displayed and pass/fail status. Detailed output is disabled by default when running tests in parallel. //parallel_process_delay: 1000, // Specifies the delay (in milliseconds) between starting the child processes when running in parallel mode. webdriver: { "keep_alive": true // Enable HTTP Keep-Alive. If set to true the keepAlive option is enabled with default settings (keepAliveMsecs = 3000). If set to an object, can specify specify the keepAliveMsecs value. }, // This object contains all the test related options. test_settings: { default: { disable_error_log: false, // Set this to true if you'd like to not display errors during the execution of the test (they are shown at the end always). launch_url: "http://localhost", // A url which can be used later in the tests as the main url to load. Can be useful if your tests will run on different environments, each one with a different url. silent: true, // Whether to show the extended HTTP traffic command logs from the WebDriver or Selenium server. use_xpath: false, // Use xpath as the default locator strategy test_workers: { "enabled": true, "workers": 20 }, // Whether or not to run individual test files in parallel. If set to `true`, runs the tests in parallel and determines the number of workers automatically. If set to an object, can specify specify the number of workers as `"auto"` or a `number`. globals: require('./globals'), // An object which will be made available within the test and can be overwritten per environment screenshots: { enabled: true, path: FAILURES_ERRORS_PATH, on_failure: true }, desiredCapabilities: { // An object which will be passed to the Selenium WebDriver when a new session will be created. You can specify browser name for instance along with other capabilities. browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true, browserTag: "mttestcr" }, end_session_on_fail: true, // End the session automatically when the test is being terminated, usually after a failed assertion. skip_testcases_on_fail: true, // Skip the remaining testcases (or test steps) from the same test suite (i.e. test file), when one testcase fails. detailed_output: true, // By default detailed assertion output is displayed while the test is running. Set this to `false` if you'd like to only see the test case name displayed and pass/fail status. This is especially useful when running tests in parallel. webdriver: { start_process: true, // When this is enabled, the Webdriver server is run in background in a child process and started/stopped automatically. Nightwatch includes support for managing Chromedriver, Geckodriver (Firefox), Safaridriver, and Selenium Server. Please refer to the Install Webdriver section for details. server_path: (Services.chromedriver ? Services.chromedriver.path : '') // Only useful if start_process is enabled. }, }, firefox: { desiredCapabilities: { browserName: 'firefox', alwaysMatch: { // Enable this if you encounter unexpected SSL certificate errors in Firefox acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ // '-verbose' '--window-size=1920,925', ] } }, javascriptEnabled: true, acceptInsecureCerts: true, acceptSslCerts: true, nativeEvents: true, browserTag: "mttestff" }, webdriver: { start_process: true, port: 4444, server_path: (Services.geckodriver ? Services.geckodriver.path : ''), cli_args: [ // List of cli arguments to be passed to the Webdriver process. This varies for each Webdriver implementation. // very verbose geckodriver logs // '-vv' ] }, }, h_firefox: { desiredCapabilities: { browserName: 'firefox', alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ '-headless', // '-verbose' '--window-size=1920,925', '--no-sandbox', ] } }, javascriptEnabled: true, acceptInsecureCerts: true, acceptSslCerts: true, nativeEvents: true, browserTag: "mttestff" }, webdriver: { start_process: true, port: 4444, server_path: (Services.geckodriver ? Services.geckodriver.path : ''), cli_args: [ // very verbose geckodriver logs // '-vv' ] }, }, chrome: { desiredCapabilities: { browserName: 'chrome', loggingPrefs: { browser: "ALL" }, javascriptEnabled: true, acceptSslCerts: true, '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: false, args: [ '--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', '--disable-software-rasterizer', '--disable-gpu', '--window-size=1920,925', '--log-level=3', '--disable-logging' ], prefs: { "profile.default_content_setting_values.cookies": 1, // Allow sites to save and read cookie data (recommended): 2=Blocked, 1=Allow }, } }, webdriver: { start_process: true, port: 9515, server_path: (Services.chromedriver ? Services.chromedriver.path : ''), cli_args: [ // --verbose ] }, }, h_chrome: { desiredCapabilities: { browserName: 'chrome', loggingPrefs: { browser: "ALL" }, javascriptEnabled: true, acceptSslCerts: true, '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: false, args: [ '--no-sandbox', '--ignore-certificate-errors', '--allow-insecure-localhost', '--headless', '--disable-gpu', '--disable-software-rasterizer', //'--verbose', '--window-size=1920,925', '--log-level=3', '--disable-logging' ], prefs: { "profile.default_content_setting_values.cookies": 1, // Allow sites to save and read cookie data (recommended): 2=Blocked, 1=Allow }, }, }, webdriver: { start_process: true, port: 9515, server_path: (Services.chromedriver ? Services.chromedriver.path : ''), cli_args: [ // --verbose ] }, }, edge: { desiredCapabilities: { browserName: 'MicrosoftEdge', acceptSslCerts: true, 'ms:edgeOptions': { w3c: false, // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options args: [ ] }, browserTag: "mtteste" }, webdriver: { start_process: true, // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ // and set the location below: server_path: "C:\\Windows\\System32\\msedgedriver.exe", cli_args: [ // --verbose ] }, }, h_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: [ '--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', '--headless', '--window-size=1920,925', '--log-level=3', '--disable-gpu', '--disable-software-rasterizer', ] }, browserTag: "mtteste" }, webdriver: { start_process: true, // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ // and set the location below: server_path: "C:\\Windows\\System32\\msedgedriver.exe", cli_args: [ // --verbose ] }, }, ////////////////////////////////////////////////////////////////////////////////// // 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: false, host: '127.0.0.1', port: 4444, launch_url: 'http://localhost', server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''), screenshots: { enabled: true, path: FAILURES_ERRORS_PATH, on_failure: true }, 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', javascriptEnabled: true, acceptSslCerts: true, acceptInsecureCerts: true, chromeOptions: { w3c: false, args: [ '--no-sandbox', '--ignore-certificate-errors', '--allow-insecure-localhost', '--headless', '--disable-gpu', '--disable-software-rasterizer', //'--verbose', '--window-size=1920,925', '--log-level=3', '--disable-logging' ] } }, webdriver: { start_process: 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.0.7
npm --version 6.14.13
yarn --version -
node --version v14.17.1
Browser driver Version
chromedriver 97.0.0
selenium-server 3.141
OS Version
Windows 10 Home 21H1
beatfactor commented 2 years ago

Are there any selenium or chromedriver logs being created?

chriscuba23 commented 2 years ago

@beatfactor yes but I don't think they can help much

Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. [1645089598.314][WARNING]: This version of ChromeDriver has not been tested with Chrome version 98.

beatfactor commented 2 years ago

can you try a few things please?

chriscuba23 commented 2 years ago

Thanx for your reply

this error occured for npx nightwatch -e chrome ecosia.js --verbose image

I have created also a bash script to catch the error

#!/bin/bash
npx nightwatch -e chrome ecosia.js --verbose   
# will print nodes exit code, e.g. 0 for success
echo $?

this message appears in the console and presumably exit code is 1:

image

beatfactor commented 2 years ago

well it looks like you're trying to run nightwatch using a custom script which no longer works. Do you have a nightwatch.js file in your project and if so can you paste the contents here?

chriscuba23 commented 2 years ago

of course

require('./node_modules/nightwatch/bin/runner.js');

beatfactor commented 2 years ago

can you maybe join the discord chat and we can help you there? https://discord.com/invite/SN8Da2X