尝试启动 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)
在命令提示符下尝试此(netstat -a)以查看此端口(4444 - Selenium 默认端口)是否正在被其他服务或侦听使用。
或者
使用不同的端口启动 selenium。
例子:
java -jar selenium-server.jar -port 5561
谢谢,
阿拉
在您的任何浏览器中运行它:
当然你可以释放端口。按照以下步骤释放端口
由于您遇到了未处理的异常错误,因此您可能应该将这一点引起 Selenium 作者的注意。他们有一个bugtracker应该使用。
根本原因似乎是Unrecognized Windows Sockets error: 0: JVM_Bind 这一行。快速谷歌搜索表明这不是一个独特的问题。