使用 PhantomJS 的 Grunt Nightwatch - "Connection refused"
Grunt Nightwatch with PhantomJS - "Connection refused"
首先,我启动 Selenium:
nohup java -jar selenium/selenium-server-standalone-2.47.1.jar -role hub -port 4455&
然后添加PhantomJS驱动:
nohup phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4455&
nohup.out 中的输出看起来...成功了吗?:
13:22:52.127 INFO - Launching Selenium Grid hub
2015-12-07 13:22:52.789:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2015-12-07 13:22:52.833:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2015-12-07 13:22:52.845:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.0.0:4455
13:22:52.846 INFO - Nodes should register to http://192.168.10.67:4455/grid/register/
13:22:52.846 INFO - Selenium Grid hub is up and running
PhantomJS is launching GhostDriver...
[INFO - 2015-12-07T13:22:56.097Z] GhostDriver - Main - running on port 8080
[INFO - 2015-12-07T13:22:56.097Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4455' using '127.0.0.1:8080'
13:22:56.177 INFO - Registered a node http://127.0.0.1:8080
[INFO - 2015-12-07T13:22:56.184Z] HUB Register - register - Registered with grid hub: http://127.0.0.1:4455/ (ok)
package.json 中的版本包括:
"devDependencies": {
"grunt": "^0.4.5",
"grunt-nightwatch": "^0.4.8",
"phantomjs": "^1.9.19"
},
我的 Nightwatch Grunt 任务配置如下:
module.exports = {
options: { // default
standalone: false,
globals_path: 'test/globals.js',
custom_commands_path: 'test/commands',
custom_assertions_path: 'test/asserts',
page_objects_path: 'test/pages',
src_folders: ['test/specs'],
output_folder: 'test/report',
test_settings: {
"default": {
"desiredCapabilities": {
"browserName": "firefox"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},
"phantomjs": {
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"acceptSslCerts": true,
"phantomjs.binary.path": "node_modules/phantomjs/bin"
}
}
},
selenium: {
"start_process": false
}
}
};
此时我可以:
grunt nightwatch:phantomjs
这给了我:
Connection refused! Is selenium server started?
怎么了?我该如何调试它?这与它说节点应该注册到 192.168.10.67(我机器的本地网络 IP)有关,但 GhostDriver 正在注册到 127.0.0.1 吗?
我认为问题出在这一行:
selenium: {
"start_process": false
}
应更改为:
selenium: {
"start_process": true
}
在您的 Grunt 任务配置中,Nightwatch.This 将在运行测试时自动启动 Selenium 进程。如果设置为 false,则必须手动启动 Selenium 进程。
首先,我启动 Selenium:
nohup java -jar selenium/selenium-server-standalone-2.47.1.jar -role hub -port 4455&
然后添加PhantomJS驱动:
nohup phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4455&
nohup.out 中的输出看起来...成功了吗?:
13:22:52.127 INFO - Launching Selenium Grid hub
2015-12-07 13:22:52.789:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2015-12-07 13:22:52.833:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2015-12-07 13:22:52.845:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.0.0:4455
13:22:52.846 INFO - Nodes should register to http://192.168.10.67:4455/grid/register/
13:22:52.846 INFO - Selenium Grid hub is up and running
PhantomJS is launching GhostDriver...
[INFO - 2015-12-07T13:22:56.097Z] GhostDriver - Main - running on port 8080
[INFO - 2015-12-07T13:22:56.097Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4455' using '127.0.0.1:8080'
13:22:56.177 INFO - Registered a node http://127.0.0.1:8080
[INFO - 2015-12-07T13:22:56.184Z] HUB Register - register - Registered with grid hub: http://127.0.0.1:4455/ (ok)
package.json 中的版本包括:
"devDependencies": {
"grunt": "^0.4.5",
"grunt-nightwatch": "^0.4.8",
"phantomjs": "^1.9.19"
},
我的 Nightwatch Grunt 任务配置如下:
module.exports = {
options: { // default
standalone: false,
globals_path: 'test/globals.js',
custom_commands_path: 'test/commands',
custom_assertions_path: 'test/asserts',
page_objects_path: 'test/pages',
src_folders: ['test/specs'],
output_folder: 'test/report',
test_settings: {
"default": {
"desiredCapabilities": {
"browserName": "firefox"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome"
}
},
"phantomjs": {
"desiredCapabilities": {
"browserName": "phantomjs",
"javascriptEnabled": true,
"acceptSslCerts": true,
"phantomjs.binary.path": "node_modules/phantomjs/bin"
}
}
},
selenium: {
"start_process": false
}
}
};
此时我可以:
grunt nightwatch:phantomjs
这给了我:
Connection refused! Is selenium server started?
怎么了?我该如何调试它?这与它说节点应该注册到 192.168.10.67(我机器的本地网络 IP)有关,但 GhostDriver 正在注册到 127.0.0.1 吗?
我认为问题出在这一行:
selenium: {
"start_process": false
}
应更改为:
selenium: {
"start_process": true
}
在您的 Grunt 任务配置中,Nightwatch.This 将在运行测试时自动启动 Selenium 进程。如果设置为 false,则必须手动启动 Selenium 进程。