我尝试在My Windows 8计算机上设置Nightwatch.js
我安装了nodejs,nightwatch和selenium-standalone-sever 3.0.0-beta1.jar。 当我尝试运行我的sample.js测试时,我收到以下错误。
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ state: 'unhandled error',
sessionId: null,
hCode: 847580505,
value:
{ localizedMessage: 'The path to the driver executable must be set by the web
driver.gecko.driver system property; for more information, see https://github.co
m/mozilla/geckodriver. The latest version can be downloaded from https://github.
com/mozilla/geckodriver/releases',
cause: null,
suppressed: [],
message: 'The path to the driver executable must be set by the webdriver.ge
cko.driver system property; for more information, see https://github.com/mozilla
/geckodriver. The latest version can be downloaded from https://github.com/mozil
la/geckodriver/releases',
hCode: 294316877,
class: 'java.lang.IllegalStateException',
screen: null },
class: 'org.openqa.selenium.remote.Response',
status: 13 }
我的配置文件是:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" :"",
"custom_assertions_path" :"",
"page_objects_path" :"",
"globals_path":"",
"selenium": {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
和我的sample.js文件是:
module.exports = {
'Demo test Google' : function (browser) {
browser
.windowMaximize()
.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();
}
};
答案 0 :(得分:1)
所需的功能应如下所示, 但我不确定nightwatch js是否支持webdriver 3.0 。
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"marionette": true
}
cli_arguments应该有geckodriver的路径。
"cli_args" : {
"webdriver.gecko.driver": "<path-to-geckodriver>"
}
您可以从此处下载geckodriver:https://github.com/mozilla/geckodriver/releases
有关详情:https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
答案 1 :(得分:0)
您尚未启动selenium服务器。您可以手动执行此操作,或者夜间监视可以为您执行此操作
"selenium": {
"start_process" : true, // let nigthwatch to start selenium server
"server_path" : "./selenium-server-standalone.jar", // provide path to selenium server jar
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : ""
}
}
答案 2 :(得分:0)
brew install geckodriver
然后你通过
将你的驱动程序更改为firefox"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}