我正在使用 nightwatch 来测试我的 javascript 应用程序。我需要能够在本地机器上运行跨浏览器测试。Chrome 和 Firefox 都可以,但是在 IE 上运行测试时出现错误:
Running: google.com
TypeError: undefined is not a function
at pass (C:\Users\Dávid\AppData\Roaming\npm\node_modules\nightwatch\lib\api\
assertions\urlContains.js:23:18)
at Object.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\night
watch\lib\core\assertion.js:94:23)
at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:299:20)
at HttpRequest.emit (events.js:110:17)
at HttpRequest.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modules\
nightwatch\lib\index.js:346:15)
at HttpRequest.emit (events.js:118:17)
at IncomingMessage.<anonymous> (C:\Users\Dávid\AppData\Roaming\npm\node_modu
les\nightwatch\lib\http\request.js:150:16)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
IEDriverServer 和 selenium 一样是 2.45.0 版本。我在 64b Windows 8.1 上使用 x64 版本。而且我已经完成了 IE11 的注册表操作。
测试文件:
module.exports = {
'google.com': function(browser){
return browser
.url('www.google.com')
.pause(5000)
.assert.urlContains('google')
.end();
}
}
nightwatch.json:
{
"src_folders" : ["./tests/e2e"],
"output_folder" : "./tests/reports",
"custom_assertions_path" : "",
"globals_path" : "",
"live_output" : false,
"parallel_process_delay" : 10,
"disable_colors": false,
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-2.45.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "./bin/IEDriverServer.exe",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:3001",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome": {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"ie": {
"desiredCapabilities": {
"browserName" : "internet explorer",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
运行命令:
nightwatch --env ie
它在这一行失败:
.assert.urlContains('google')
提前感谢所有帮助。