Closed chan-chandra closed 2 years ago
@beatfactor @gravityvi @senocular could you please check on this issue, Thank you
@chan-chandra could you try this config instead:
chrome: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
// w3c:false 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'
]
}
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// --verbose
]
}
},
I suggest starting with the Quickstart Tutorial and if needed to run in headless, just pass the --headless
argument (only works in Chrome, Edge, and Firefox).
Test fail to run in headless mode when using NightwatchJS
steps
nightwatch.conf.js
file, it shows errorTried adding the following ways 1
Example test
Demo.js
``` module.exports = { 'Demo test ecosia.org' : function(browser) { browser .url('https://www.ecosia.org/') .waitForElementVisible('body') .assert.titleContains('Ecosia') .assert.visible('input[type=search]') .setValue('input[type=search]', 'nightwatch') .assert.visible('button[type=submit]') .click('button[type=submit]') .assert.containsText('.mainline-results', 'Nightwatch.js') .end(); } }; ``` **Run with command** ```sh $ nightwatch test/demo.js ``` ### Verbose output
## Configuration
## Your Environment
| Executable | Version |
| ---: | :--- |
| `nightwatch --version` | 1.7.13 |
| `npm --version` | 6.14.13 |
| `node --version` | 14.17.2 |
| OS | Version |
| --- | --- |
| macOS Monterey | 12.1 |
debug.log
``` FAILED: 1 assertions failed, 1 errors and 4 passed (10.322s) _________________________________________________ TEST FAILURE: 1 error during execution; 1 assertions failed, 4 passed (11.023s) ✖ Demo – Demo test ecosia.org (10.322s) Testing if element <.mainline-results> contains text 'Nightwatch.js' in 5000ms - expected "contains text 'Nightwatch.js'" but got: "element could not be located" (5487ms) at Object.Demo test ecosia.org (/Users/chanagonda/Documents/coe/qa-coe-experiments/nightwatchJS/tests/Demo.js:15:17) at processTicksAndRejections (internal/process/task_queues.js:95:5) NoSuchElementError: An error occurred while running .getText() command on <.mainline-results>: {"sessionId":"cde60139e1a3a480002b3dccedac52bf","status":0,"value":[]} at processTicksAndRejections (internal/process/task_queues.js:95:5) npm ERR! Test failed. See above for more details. ```
nightwatch.conf.json
```js module.exports = { "src_folders" : ["tests"], "webdriver" : { "start_process": true, "server_path": "node_modules/.bin/chromedriver", "port": 9515 }, "test_settings" : { "default" : { "desiredCapabilities": { "browserName": "chrome", "chromeOptions" : { "w3c": false, "args" : ["headless", "no-sandbox", "disable-gpu"], "binary": "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" }, acceptSslCerts: true } } }, } ```