简体   繁体   English

在运行简单的 selenium+java 代码时遇到异常?

[英]getting an exception on running simple selenium+java code?

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.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'PRAVUDHAS', ip: '192.168.43.15', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    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 AlertClass.main(AlertClass.java:14)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:?????/status] to be available after ????? ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
    ... 9 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 10 more

Download the latest ChromeDriver for your operating system here. 在此处为您的操作系统下载最新的 ChromeDriver。

  • Upgrade ChromeDriver.升级 ChromeDriver。
  • Execute netstat command through CLI to see if you have reached limit of possible open connections or check if there is another application running on the given port.通过 CLI 执行 netstat 命令以查看您是否已达到可能打开的连接的限制,或者检查给定端口上是否有另一个应用程序正在运行。
  • Set Driver Path.设置驱动程序路径。
  • Check your firewall settings, there is a chance that firewall configuration may be causing the issue.检查您的防火墙设置,防火墙配置可能会导致问题。

You need to have the.exe driver in the same directory of your project.您需要将 .exe 驱动程序放在项目的同一目录中。 If you use chrome - download chrome driver.如果您使用 chrome - 下载 chrome 驱动程序。 If you use firefox - download firefox driver.如果您使用 firefox - 下载 firefox 驱动程序。 etc.等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM