我让Selenium和Chrome完美运行,但自上周以来它已不再适用了。这就是我得到的:
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
System info: host: 'Scs-MacBook-Pro.local', ip: 'fe80:0:0:0:8d7:2cd3:84d5:161%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:146)
... 14 more
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:174)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:183)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:179)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 19 more
13:04:18.947 WARN - Exception: The process has not exited yet therefore no result is available ...
13:04:47.978 INFO - Executing: [new session: Capabilities [{acceptSslCerts=true, name=Incart Fi, browserName=chrome, javascriptEnabled=true, platform=ANY}]])
13:04:47.979 INFO - Creating a new session for Capabilities [{acceptSslCerts=true, name=Incart Fi, browserName=chrome, javascriptEnabled=true, platform=ANY}]
Starting ChromeDriver 2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9) on port 29092
Only local connections are allowed.
现在我想知道为什么,因为我没有改变任何设置。它启动了safari浏览器,但是来自nightwatch的waitForElement不起作用。所以有人可以通过错误告诉我为什么我遇到这个问题?
{
"_comment": "./selenium-server-standalone-3.0.1.jar",
"_comment2": "/Users/SCMacBook/node_modules/chromedriver/bin/chromedriver",
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "./selenium-server-standalone-3.1.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "/Users/SCMacBook/webdriver/chromedriver",
"webdriver.gecko.driver" : "/Users/SCMacBook/webdriver/geckodriver",
"webdriver.firefox.profile" : "nightwatch"
}
},
"test_settings" : {
"default" : {
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "./pics/"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true
}
},
"firefox" : {
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"safari" : {
"desiredCapabilities": {
"browserName": "safari"
}
},
"edge" : {
"desiredCapabilities": {
"platform": "WIN10",
"browserName": "MicrosoftEdge"
}
},
"ie" : {
"desiredCapabilities": {
"platform": "WIN10",
"browserName": "internet explorer",
"acceptSslCerts" : false
}
}
}
}
答案 0 :(得分:2)
我的解决方案很简单,我觉得特别愚蠢。不知怎的,我的/ etc / hosts文件被更改了(MAMP?我的错?)和
127.0.0.1 localhost
部分遗失了。因此机器无法将localhost用作127.0.0.1
希望有一天这会帮助一个可怜的人:/
答案 1 :(得分:1)
运行nightwatch.js测试时也出现了同样的错误,我的问题也是由于/ etc / hosts文件输入错误造成的:
0.0.0.0 localhost
删除上述条目后,错误消失了。