Selenium 夜视彩色显示器
我无法运行nightwatch在chrome上运行测试 以下是我从nightwatch示例下载的修改后的nightwatch.json:Selenium 夜视彩色显示器,selenium,nightwatch.js,Selenium,Nightwatch.js,我无法运行nightwatch在chrome上运行测试 以下是我从nightwatch示例下载的修改后的nightwatch.json: { "src_folders" : ["./examples/tests"], "output_folder" : "./examples/reports", "custom_commands_path" : "./examples/custom-commands", "custom_assertions_path" : "", "glob
{
"src_folders" : ["./examples/tests"],
"output_folder" : "./examples/reports",
"custom_commands_path" : "./examples/custom-commands",
"custom_assertions_path" : "",
"globals_path" : "./examples/globals.json",
"live_output" : false,
"selenium" : {
"start_process" : false,
"server_path" : "/lib/sel-serv.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/lib/chromedriver/chromedriver.exe",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"chrome":{
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
},
"desiredCapabilities": {
"name" : "test-example",
"browserName": "chrome"
},
"globals" : {
"myGlobal" : "some_sauce_global"
},
"selenium" : {
"start_process" : false
}
}
}
我得到这个错误信息:
ERROR There was an error while starting the test runner:
Error: Invalid testing environment specified: chrome
at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:448:15)
at Object.CliRunner.init (/usr/local/lib/node_modules/nightwatch/lib/runner/cli/clirunner.js:49:8)
at module.exports.runner.runner (/usr/local/lib/node_modules/nightwatch/lib/index.js:546:17)
at /usr/local/lib/node_modules/nightwatch/bin/runner.js:9:16
at module.exports.cli.cli (/usr/local/lib/node_modules/nightwatch/lib/index.js:504:5)
at Object.<anonymous> (/usr/local/lib/node_modules/nightwatch/bin/runner.js:8:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
我还发现了一篇旧帖子,上面说你必须在根目录中创建新文件,所以尝试一下,什么都没有发生。我想你需要在lib之前加一个点:
"webdriver.chrome.driver" : "./lib/chromedriver/chromedriver.exe",
还有selenium.jar:
"server_path" : "./lib/sel-serv.jar",
我想你需要在lib之前加一个点:
"webdriver.chrome.driver" : "./lib/chromedriver/chromedriver.exe",
还有selenium.jar:
"server_path" : "./lib/sel-serv.jar",
如果您的chromedriver和selenium standalone jar在您指向的文件中,那么我认为您只是缺少在测试运行之前启动服务器的配置。看到那条线了吗
"start_process" : false,
你需要把它设置为真,就像这样
"start_process" : true,
除非您计划在运行测试之前手动启动服务器。一旦完成,考虑上面提到的路径。取决于是否在Windows、Mac或Linux上运行;这可能需要以下步骤。在/前面,如果您的chromedriver和selenium standalone jar在您指向的文件中,那么我认为您只缺少在测试运行之前启动服务器的配置。看到那条线了吗
"start_process" : false,
你需要把它设置为真,就像这样
"start_process" : true,
除非您计划在运行测试之前手动启动服务器。一旦完成,考虑上面提到的路径。取决于是否在Windows、Mac或Linux上运行;这可能需要以下步骤。在/前面的Selenium服务器jar路径和chrome驱动程序.exe路径设置不正确。 使用圆点。在设置路径之前表示您的工作目录。或者删除正斜杠/before-chrome驱动程序和selenium服务器jar文件路径 您必须手动运行Selenium server standalone jar文件,因为您尚未将start_process设置为true。在此处检查Selenium配置: 您已将start_process属性设置为false两次。从json文件中删除最后一个元素。硒:{ 启动进程:false }
在开始执行之前,还要检查浏览器版本和驱动程序是否兼容。检查从中下载驱动程序的自述文件。自述文件的顶行将具有浏览器兼容版本。Selenium服务器jar路径和chrome驱动程序.exe路径设置不正确。 使用圆点。在设置路径之前表示您的工作目录。或者删除正斜杠/before-chrome驱动程序和selenium服务器jar文件路径 您必须手动运行Selenium server standalone jar文件,因为您尚未将start_process设置为true。在此处检查Selenium配置: 您已将start_process属性设置为false两次。从json文件中删除最后一个元素。硒:{ 启动进程:false }
在开始执行之前,还要检查浏览器版本和驱动程序是否兼容。检查从中下载驱动程序的自述文件。自述文件的顶行将具有浏览器兼容版本。只需检查配置文件并将chrome对象从默认对象中删除,如
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
}
},
"chrome":{
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
like this....have a blast
只需检查配置文件并将chrome对象从默认对象中移出,如
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"disable_colors": false,
"screenshots" : {
"enabled" : false,
"path" : ""
}
},
"chrome":{
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
like this....have a blast
chrome驱动程序的夜视配置将是-
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"page_objects_path": "./pages",
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-3.4.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
在这里,chrome已成为默认broswer。chrome驱动程序的夜视配置将被禁用-
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"page_objects_path": "./pages",
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-3.4.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
"selenium": {
"start_process": true,
"server_path": "./lib/drivers/selenium-server-standalone-3.141.59.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./lib/drivers/chromedriver.exe",
"webdriver.gecko.driver": "",
"webdriver.edge.driver": ""
}
},
在这里,chrome已成为默认broswer
"selenium": {
"start_process": true,
"server_path": "./lib/drivers/selenium-server-standalone-3.141.59.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./lib/drivers/chromedriver.exe",
"webdriver.gecko.driver": "",
"webdriver.edge.driver": ""
}
},
你应该这样写你的nightwatch.json。
此外,请确保您的web驱动程序与您的chrome浏览器的版本相同,如果它不在同一版本中,它将不会运行,并且不会给您任何错误消息
你应该这样写你的nightwatch.json。
此外,请确保您的web驱动程序与chrome浏览器的版本相同,如果它与chrome浏览器的版本不同,它将不会运行,并且不会给您任何错误消息您可以尝试使用相对目录而不是绝对目录吗?我猜你放在配置文件中的路径不是chrome驱动程序所在的路径这是chrome驱动程序的路径。我把它放在那里,第二个猜测是,夜间监视不支持绝对路径。如果你做一个相对路径,它能工作吗。我使用了一个相对路径lib/chromedriver/chromedriver.exe,但没有使用。我也尝试过./lib/chromedriver/chromedriver.exe,但现在我得到了一个路径错误。chrome驱动程序是否实际位于lib/chromedriver文件夹中,相对于您的配置文件/启动测试的位置?您是否可以尝试使用相对目录而不是绝对目录?我猜你放在配置文件中的路径不是chrome驱动程序所在的路径这是chrome驱动程序的路径。我把它放在那里,第二个猜测是,夜间监视不支持绝对路径。如果你做一个相对路径,它能工作吗。我使用了一个相对路径lib/chromedriver/chromedriver.exe,但没有使用。我也试过了./lib/chromedriver/chromedriver.exe,但是现在我得到了一个路径错误。chrome驱动程序实际上在lib/chromedriver文件夹中吗 er相对于您的配置文件/从何处启动测试?