尝试启动 selenium 时出现以下错误:
C:\Temp\selenium-server-1.0.3>java -jar selenium-server.jar
22:02:07.615 INFO - Java: Sun Microsystems Inc. 16.0-b13
22:02:07.617 INFO - OS: Windows 7 6.1 x86
22:02:07.625 INFO - v2.0 [a2], with Core v2.0 [a2]
22:02:07.811 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
22:02:07.813 INFO - Version Jetty/5.1.x
22:02:07.815 INFO - Started HttpContext[/selenium-server/driver,/selenium-server /driver]
22:02:07.817 INFO - Started HttpContext[/selenium-server,/selenium-server]
22:02:07.818 INFO - Started HttpContext[/,/]
22:02:07.866 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@2bbd86
22:02:07.867 INFO - Started HttpContext[/wd,/wd]
22:02:07.870 WARN - Failed to start: [email protected]:4444
Exception in thread "main" org.openqa.jetty.util.MultiException[java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind]
at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:686)
at org.openqa.jetty.util.Container.start(Container.java:72)
at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:396)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:234)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:198)
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.openqa.jetty.util.ThreadedServer.newServerSocket(ThreadedServer.java:391)
at org.openqa.jetty.util.ThreadedServer.open(ThreadedServer.java:477)
at org.openqa.jetty.util.ThreadedServer.start(ThreadedServer.java:503)
at org.openqa.jetty.http.SocketListener.start(SocketListener.java:204)
at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:716)
at org.openqa.jetty.util.Container.start(Container.java:72)
at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:396)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:234)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:198)
Java 已安装:
C:\Temp\selenium-server-1.0.3>java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
答案1
在命令提示符下尝试此命令(netstat -a)来查看此端口(4444 - Selenium 默认端口)是否正在被其他服务或监听使用。
或者
使用不同的端口启动 selenium。
例子:
java -jar selenium-server.jar -端口 5561
谢谢,
阿糖胞苷
答案2
当然你可以释放端口。按照以下步骤释放端口
- 在命令提示符下输入“Netstat -a -n -o”
- 注意 PID 对应于您要释放的端口
- 输入命令‘tasklist /svc /FI "PID eq <>"’
- 请注意命令提示符中列出的任务名称(图像名称下方)
- 从任务管理器中终止该任务