I'm currently trying to set up an Nightwatch project, to see if it's any good. I'm following This tutorial right now. The stuff from the tutorial works, but when I try to modify it a little bit, it doesn't work anymore. I looked over the Developer API guide, but I guess I'm still missing something? Code I use is pasted below:
var conf = require('../../nightwatch.conf.js');
module.exports = {
'Demo test' : function (browser) {
browser
.url('http://localhost/myWebsite?newwindow=0')
.waitForElementVisible('body', 6000)
.setValue('input[name=txtLogin]', 'login')
.setValue('input[name=txtPassword]', 'password')
.waitForElementVisible('input.btnLogin', 2000)
.click('button[id=btnLogin]')
.pause(6000)
.assert.elementPresent("#selectTitle")
.assert.containsText('#selectTitle', 'schedules')
.assert.urlContains('login/login_start.asp')
.saveScreenshot(conf.imgpath(browser) + 'titleScreen.png')
.end();
}
};
Error in cmd:
Running: Demo test
√ Element <body> was visible after 41 milliseconds.
ERROR: Unable to locate element: "input[name=txtLogin]" using: css selector
at Object.Demo test (C:\Workspace\myWebsite\learn-nightwatch\test\e2e\UGPRO_Test.js:8:8)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
ERROR: Unable to locate element: "input[name=txtPassword]" using: css selector
at Object.Demo test (C:\Workspace\myWebsite\learn-nightwatch\test\e2e\UGPRO_Test.js:9:8)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
× Timed out while waiting for element <input.btnLogin> to be present for 2000 milliseconds. - expected "visible" but got: "not found"
at Object.Demo test UltraGendaPro (C:\Workspace\ultragendapro\learn-nightwatch\test\e2e\UGPRO_Test.js:10:8)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
Aucun commentaire:
Enregistrer un commentaire