【发布时间】:2015-01-29 06:21:50
【问题描述】:
我继承了一个没有文档的工作项目。这是一个sails.js 应用程序。 有一小部分单元测试和一个端到端测试。
当我尝试使用 grunt 运行端到端测试时。我明白了:
$ grunt e2e
Running "nightwatch" task
started - PID: 5440
>> Executing "default" tests (standalone)
[Index] Test Suite
==================
Running: Should clean the collection
removing 0 places
>> Connection refused! Is selenium server started?
我不知道我会错过什么。这让我卡了一个多星期。
该项目在 grunt-nightwatch 中有一个 selenium-server-standalone-2.40.0.jar。所以我取的PID是selenium server启动的。如果我先启动罐子(在咕噜声之外),我会得到
$ grunt e2e
org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
18:38:46.189 WARN - Failed to start: SocketListener0@0.0.0.0:4444
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:491)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:300)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:95)
>> Could not start Selenium.
这是 nightwatch.json
{
"src_folders" : ["tests/e2e"],
"custom_commands_path" : "",
"custom_assertions_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": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
非常感谢您的帮助!
附言我在 Windows 7 盒子上
【问题讨论】:
-
您是否启动了 Selenium?你的 Selenium 运行什么地址?请在您的问题中解释更多细节。
-
嗨@AntônioCarlos 我已经更新了问题,但不确定要添加哪些其他信息。
-
看看“Selenium 已经在端口 4444 上运行”。然后,将您的测试配置为在localhost:4444 中运行。你用茉莉花吗?
-
我在 nightwatch.json 中看到了 chrome.. 但我不知道这是什么意思
-
您能否提供更多有关您的 nightwatch.json 和测试套件的详细信息?
标签: javascript node.js testing selenium sails.js