I am trying to debug in nightwatch. When I put in a console.log it prints before the test runs - while its doing some sort of construction/compiling of the test. I tried also visual studio code debugger and same thing - the breakpoint hits before the tests are actually run. thanks for help - mark
You can add Nightwatch to your project simply by running npm install nightwatch --save-dev .
Nightwatch. js is an open-source automated testing framework that is powered by Node. js and provides complete E2E (end to end) solutions to automation testing with Selenium Javascript be it for web apps, browser apps, and websites.
json is a configuration file which tells the Nightwatch tool where to find the stand-alone Selenium binary, browser drivers, location of the test, environment profile, and more. The package.json contains the metadata and node package dependencies for the project. The ci/functional-test.
Nightwatch. js is an integrated, easy to use End-to-End testing solution for web applications and websites, written in Node. js. It uses the W3C WebDriver API to drive browsers and perform commands and assertions on DOM elements.
"nightwatch" is built on node.js. Node.js executes statements asynchronously. If you write console.log();
, it will be executed asynchronously.
The statements you write using browser
(or client
) object (e.g. browser.url();
, browser.click();
etc.) will be queued up at Selenium Server. They are also executed asynchronously by node.js but are queued up at selenium server.
To perform console.log()
in sync with other statements in nightwatch, use .perform()
. You will get output in sync with other statements.
var elementValue;
browser
.getValue('.some-element', function(result) {
elementValue = result.value;
})
// other stuff going on ...
//
// self-completing callback
.perform(function() {
console.log('elementValue', elementValue);
// without any defined parameters, perform
// completes immediately (synchronously)
})
.end();
For debugging purpose, you can stop the execution to find out element values or check the browser related data. Use this command: browser.pause();
(or client.pause();
). Do not pass any timer here. It will stop the execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With