After following the steps outlined in , I incorporated the code snippet from into my test file.
module.exports = {
'Demo test Google' : function (browser) {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end();
}
};
This is how my package.json is structured:
{
"name": "try_nw",
"version": "1.0.0",
"description": "try_nightwatch",
"main": "nightwatch.js",
"scripts": {
"test": "node nightwatch -e chrome"
},
"author": "",
"license": "ISC",
"dependencies": {
"bower": "^1.8.2",
"chromedriver": "^2.34.0",
"geckodriver": "^1.10.0",
"nightwatch": "^0.9.19",
"selenium-server-standalone-jar": "^3.8.1"
}
}
Here's a glimpse at my nightwatch.json configuration:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"start_session" : true,
"server_path" : "bin/selenium-server-standalone-3.8.1.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "bin/chromedriver.exe",
"webdriver.gecko.driver" : "",
"webdriver.edge.driver" : ""
}
},
...
However, during the test execution, I encountered an issue where the Chrome tab remained blank with corresponding console output as seen below:
Starting selenium server... started - PID: 15024
[Googletests] Test Suite
============================
Running: Demo test Google
× Timed out while waiting for element <body> to be present for 1000
milliseconds. - expected "visible" but got: "not found"
...
FAILED: 1 assertions failed (5.972s)
_________________________________________________
TEST FAILURE: 1 assertions failed, 0 passed. (6.088s)
× googletests
- Demo test Google (5.972s)
Timed out while waiting for element <body> to be present for 1000 milliseconds. - expected "visible" but got: "not found"
at Object.Demo test Google (E:\JS\Try_NW\tests\googletests.js:6:14)
at process._tickCallback (internal/process/next_tick.js:150:11)
Process finished with exit code 1
In conclusion, it appears that the .waitForElementVisible
method is not defined. Any suggestions or solutions would be greatly appreciated!