在运行简单的Selenium+Java代码时遇到了异常?

huangapple go评论82阅读模式
英文:

getting an exception on running simple selenium+java code?

问题

Invalid port. Exiting...
无效的端口。正在退出...

SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
严重错误:org.apache.commons.exec.ExecuteException:进程以错误退出:1(退出值:1)

Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
线程“main”中的异常"org.openqa.selenium.WebDriverException:等待驱动程序服务器启动超时。

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'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'
系统信息:主机:'PRAVUDHAS',IP:'192.168.43.15',操作系统名称:'Windows 8.1',操作系统架构:'amd64',操作系统版本:'6.3',Java版本:'1.8.0_121'

Driver info: driver.version: ChromeDriver
驱动程序信息:驱动程序版本: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
由 org.openqa.selenium.net.UrlChecker$TimeoutException 引起:等待 [http://localhost:?????/status] 在 ????? 毫秒后可用

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
由 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
英文:
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 &quot;main&quot; org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: &#39;3.141.59&#39;, revision: &#39;e82be7d358&#39;, time: &#39;2018-11-14T08:25:53&#39;
System info: host: &#39;PRAVUDHAS&#39;, ip: &#39;192.168.43.15&#39;, os.name: &#39;Windows 8.1&#39;, os.arch: &#39;amd64&#39;, os.version: &#39;6.3&#39;, java.version: &#39;1.8.0_121&#39;
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.&lt;init&gt;(RemoteWebDriver.java:131)
	at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:181)
	at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(ChromeDriver.java:168)
	at org.openqa.selenium.chrome.ChromeDriver.&lt;init&gt;(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

答案1

得分: 1

在此处下载适用于您操作系统的最新ChromeDriver。

  • 升级ChromeDriver。
  • 通过CLI执行netstat命令,以查看是否已达到可能的打开连接限制,或检查给定端口上是否有其他应用程序在运行。
  • 设置驱动程序路径。
  • 检查防火墙设置,防火墙配置可能导致问题。
英文:

Download the latest ChromeDriver for your operating system here.

  • Upgrade 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.
  • Set Driver Path.
  • Check your firewall settings, there is a chance that firewall configuration may be
    causing the issue.

答案2

得分: 0

你需要将 .exe 驱动程序放在项目的同一目录中。
如果你使用 Chrome - 下载 Chrome 驱动程序。
如果你使用 Firefox - 下载 Firefox 驱动程序。
等等。

英文:

You need to have the .exe driver in the same directory of your project.
If you use chrome - download chrome driver.
If you use firefox - download firefox driver.
etc.

huangapple
  • 本文由 发表于 2020年4月7日 02:28:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/61066507.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定