我正在尝试使用Docker运行一些NightWatch测试,但似乎在CentOS上给我一个错误。当我在MacOS上尝试时,它会起作用。
我尝试更改端口,但这似乎不是问题。
终端错误
POST http://172.17.0.1:4445 /wd/hub/session - EHOSTUNREACH
Error: connect EHOSTUNREACH 172.17.0.1:4445
An error occurred while retrieving a new session: "connect EHOSTUNREACH 172.17.0.1:4445"
at Socket.socketErrorListener (_http_client.js:392:9)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
Docker网络检查桥(在CentOS和MacOS中同样显示)
[
{
"Name": "bridge",
"Id": "e18423aca6d4680052b2e28ef8c58e1d7c9c5cff2d072ac7cbeaea36bdfaa038",
"Created": "2019-05-17T16:55:37.595166623-04:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"7f6139e7dc36a944b568283967d08aa9e2410e5b2c9f28ef379ce989254fe57b": {
"Name": "selenium-firefox",
"EndpointID": "e7c61e93ff0abe2e8b55eeea9315ccc2de79bbaf733f27aaad2e63b1eb1bc620",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Nightwatch.json文件
{
"src_folders": ["./tests"],
"output_folder": "./results",
"custom_commands_path": "./commands",
"custom_assertions_path": "./assertions",
"page_objects_path": "",
"globals_path": "",
"test_workers": {
"enabled": true,
"workers": "auto"
},
"selenium": {
"start_process": false
},
"test_settings": {
"default": {
"selenium_port": 4445,
"selenium_host": "172.17.0.1",
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
},
"end_session_on_fail": false,
"skip_testcases_on_fail": false
},
"safari": {
"desiredCapabilities": {
"browserName": "safari"
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions" : {
"args" : ["--no-sandbox"]
}
}
}
}
}
Docker容器
0.0.0.0:4445->4444/tcp selenium-firefox
我希望它可以连接到selenium-firefox容器并运行测试。