我正在使用selenium server独立jar-3.11.0,最新的ChromeDriver-2.36和 Chrome版本66.0.3359.139
我的代码
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebDriverBasics {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\surya\\Downloads\\Compressed\\chromedriver_win32_2\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.facebook.com");
driver.manage().window().maximize();
}
}
但是我无法启动chrome.its给出以下错误
Invalid port. Exiting...
?? ??, ???? ??:??:?? ????????? org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'DESKTOP-5GVJDVR', ip: '192.168.0.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at WebDriverBasics.main(WebDriverBasics.java:12)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:????/status] to be available after ????? ms
at
答案 0 :(得分:0)
此错误消息......
Invalid port. Exiting...
?? ??, ???? ??:??:?? ????????? org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
...意味着 OsProcess 无法绑定到系统中指定的空闲端口。
根据讨论Getting Invalid port error.
和Invalid port. Exiting...
<强>
"Invalid port. Exiting..." occurs when the port assigned to chromedriver is less than 0 or greater than 65535.
强>
netstat
命令,查看是否已达到可能的打开连接限制,或检查给定端口上是否有其他应用程序在运行。@Test
。注意:步骤1,2,7和8对于调试/解决您目前面临的问题至关重要。
答案 1 :(得分:0)
检查驱动程序位置是否正确。我可以毫无问题地推出Facebook。
package Practice;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Facebook
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.facebook.com");
driver.manage().window().maximize();
}
}
答案 2 :(得分:0)
4 ...如果您遇到无效端口退出错误,请尝试此代码:
System.setProperty("webdriver.chrome.driver","C:\Users\Om Sai Ram\workspace\com.gmail\chromedriver.exe"); driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"), DesiredCapabilities.chrome()); driver.get("http://www.google.com"); driver.manage().window().maximize();
答案 3 :(得分:0)
我来自伊朗。我也有这个错误,花了很多时间才找到。 但最终通过将控制面板中的区域设置更改为英文来解决。
答案 4 :(得分:-1)
将日期从阿拉伯语(或其他日期)更改为英语日期。