我一直在尝试用Nightwatchjs运行一个简单的测试,但我总是遇到问题。
我相信我已经正确设置了我的JSON文件:
{
"src_folder" : ["./smoketests"],
"output_folder" : "./reports",
"selenium" : {
"start_process" : true,
"start_session" : true,
"server_path" : "M:/nightwatch/lib/selenium-server-standalone-2.48.2.jar",
"log_path" : false,
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./lib/chromedriver.exe"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://www.google.com/",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent" : true,
"screenshots" : {
"enabled" : false,
"path" : "./screenshots/smoketests"
}
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
},
"chrome" : {
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
}我的测试非常简单:
module.exports = {
beforeEach : function(browser) {
browser.maximizeWindow();
},
'Test title' : function(browser) {
browser
.url('http://www.google.com/')
.waitForElementVisible('body', 1000)
.assert.title("Google")
browser.end();
}
};然而,当我运行测试时:
nightwatch -c smoketests/homepage.json我收到以下错误:
M:\nightwatch>nightwatch -c projects/smoketests/homepage.json
Starting selenium server... started - PID: 6448
C:\Users\jomartinez\AppData\Roaming\npm\node_modules\nightwatch\lib\
runner\run.js:116
var fullPaths = testSource.map(function (p) {
^
TypeError: Cannot read property 'map' of undefined
at module.exports.readPaths (C:\Users\jomartinez\AppData\Roaming\npm\node_mo
dules\nightwatch\lib\runner\run.js:116:31)
at runner [as run] (C:\Users\jomartinez\AppData\Roaming\npm\node_modules\nig
htwatch\lib\runner\run.js:182:10)
at Object.CliRunner.runner (C:\Users\jomartinez\AppData\Roaming\npm\node_mod
ules\nightwatch\lib\runner\cli\clirunner.js:345:16)
at C:\Users\jomartinez\AppData\Roaming\npm\node_modules\nightwatch\lib\runne
r\cli\clirunner.js:321:12
at SeleniumServer.onStarted (C:\Users\jomartinez\AppData\Roaming\npm\node_mo
dules\nightwatch\lib\runner\cli\clirunner.js:281:9)
at SeleniumServer.checkProcessStarted (C:\Users\jomartinez\AppData\Roaming\n
pm\node_modules\nightwatch\lib\runner\selenium.js:140:10)
at SeleniumServer.onStderrData (C:\Users\jomartinez\AppData\Roaming\npm\node
_modules\nightwatch\lib\runner\selenium.js:120:8)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)其他人也遇到过这个问题吗?
发布于 2015-11-24 06:49:58
我想我已经弄清楚我最初的问题了。我在JSON文件中的"scr_folders“中有一个语法错误。修复之后,我的测试似乎运行得很好。
https://stackoverflow.com/questions/33881636
复制相似问题