'Nightwatch Execute Method is not returning a result
I was running a test where I obtained a POST parameter, this has to be done with Nightwatch's execute function.
Even though the function in execute returned a value, when I used that value outside of execute it's always undefined. I thought to take the usage of execute to a basic level and I ended up with this:
const executeResult = browser.execute( function(data) {
return 42;
}, [], null);
console.log(executeResult);
When I run this, executeResult is the Nightwatch object (output here)
Why on earth would that return the Nightwatch object?
I have also tried this:
const executeResult = browser.execute( function(data) {
return 42;
}, [], function( result) {
console.log(result);
});
And the same output (Nightwatch object) is shown on screen...
I have been pulling my hair for hours with this and have looked at related threads but nothing so far...would not be surprised if it's an async issue, JS always busts my **** with this xD
Any ideas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|