2

我是 Selenium IDE 的初学者。添加了插件并尝试运行测试用例。它向我显示了以下错误消息。

[info] Test case failed
[info] Test suite completed: 1 played, 1 failed
[info] Playing test case My First TC
[info] Executing: |open | / | |
[error] Could not connect to Selenium Server. Have you started the Selenium Server yet?

所以我下载了必要的jar文件并执行了以下命令java -jar selenium-server-standalone-2.28.0.jar [替换为下载的最新版本]

收到一堆消息如下:要做什么?

selenium-server-standalone-3.0.1.jar

Java 版本 java 版本 "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, 混合模式)

23:20:37.675 INFO - Selenium build info: version: '3.0.1', revision: '1969d75'
23:20:37.675 INFO - Launching a standalone Selenium Server
2017-02-10 23:20:37.691:INFO::main: Logging initialized @275ms
23:20:37.737 INFO - Driver class not found: com.opera.core.systems.OperaDriver
23:20:37.737 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped: Unable to create new instances on this machine.
23:20:37.737 INFO - Driver class not found: com.opera.core.systems.OperaDriver
23:20:37.737 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
23:20:37.737 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version=, platform =MAC}] does not match the current platform VISTA 2017-02-10 23:20:37.769:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-02-10 23:20:37.800:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5dfcfece{/,null,AVAILABLE}2017-02-10 23:20:37.815:WARN:osjuc.AbstractLifeCycle:main: FAILED ServerConnector@643b1d11{HTTP/1.1}{0.0.0.0:4444}: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Unknown Source)
    at sun.nio.ch.Net.bind(Unknown Source)
    at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
    at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
    at 

org.seleniumhq.jetty9.server.ServerConnector.open(ServerConnector.java:321)
        at org.seleniumhq.jetty9.server.AbstractNetworkConnector.doStart(Abstrac
tNetworkConnector.java:80)
        at org.seleniumhq.jetty9.server.ServerConnector.doStart(ServerConnector.
java:236)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.seleniumhq.jetty9.server.Server.doStart(Server.java:366)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.openqa.selenium.remote.server.SeleniumServer.boot(SeleniumServer.
java:147)
        at org.openqa.grid.selenium.GridLauncherV3$1.launch(GridLauncherV3.java:
229)
        at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:91)
2017-02-10 23:20:37.815:WARN:osjuc.AbstractLifeCycle:main: FAILED org.seleniumhq
.jetty9.server.Server@2ef5e5e3: java.net.BindException: Address already in use:
bind
java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.seleniumhq.jetty9.server.ServerConnector.open(ServerConnector.jav
a:321)
        at org.seleniumhq.jetty9.server.AbstractNetworkConnector.doStart(Abstrac
tNetworkConnector.java:80)
        at org.seleniumhq.jetty9.server.ServerConnector.doStart(ServerConnector.
java:236)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.seleniumhq.jetty9.server.Server.doStart(Server.java:366)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.openqa.selenium.remote.server.SeleniumServer.boot(SeleniumServer.
java:147)
        at org.openqa.grid.selenium.GridLauncherV3$1.launch(GridLauncherV3.java:
229)
        at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:91)
Usage: <main class> [options]
  Options:
    -browserTimeout
       <Integer> in seconds : number of seconds a browser session is allowed to
       hang (0 means indefinite) while a WebDriver command is running (example:
       driver.get(url)). If the timeout is reached while a WebDriver command is
still processing,
       the session will quit. Minimum value is 60. Default is 0
    -debug
       <Boolean> : enables LogLevel.FINE. Default is false (if omitted)
       Default: false
    -jettyThreads, -jettyMaxThreads
       <Integer> : max number of threads for Jetty. Default is 200
    -log
       <String> filename : the filename to use for logging. If omitted, will log

       to STDOUT
    -port
       <Integer> : the port number the server will use. Defaults to [4444]. When

       "role" is a set to [node], default is [5555]
       Default: 4444
    -role
       <String> options are [hub], [node], or [standalone] : Default is
       [standalone]
       Default: standalone
    -timeout, -sessionTimeout
       <Integer> in seconds : Specifies the timeout before the server
       automatically kills a session that hasn't had any activity in the last X
seconds. The
       test slot will then be released for another test to use. This is typicall
y
       used to take care of client crashes. For grid hub/node roles, cleanUpCycl
e
       must also be set. Default is 1800 (30 minutes)
       Default: 1800

java.lang.RuntimeException: java.net.BindException: Address already in use: bind

        at org.openqa.selenium.remote.server.SeleniumServer.boot(SeleniumServer.
java:149)
        at org.openqa.grid.selenium.GridLauncherV3$1.launch(GridLauncherV3.java:
229)
        at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:91)
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.seleniumhq.jetty9.server.ServerConnector.open(ServerConnector.jav
a:321)
        at org.seleniumhq.jetty9.server.AbstractNetworkConnector.doStart(Abstrac
tNetworkConnector.java:80)
        at org.seleniumhq.jetty9.server.ServerConnector.doStart(ServerConnector.
java:236)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.seleniumhq.jetty9.server.Server.doStart(Server.java:366)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
        at org.openqa.selenium.remote.server.SeleniumServer.boot(SeleniumServer.
java:147)
        ... 2 more
4

2 回答 2

0

这些是您可以申请并检查作品的几个步骤

) 下载 selenium 独立 jar 文件。

2)粘贴到lib文件夹中的jar文件中。

3)project->properties->java build path->Add jar->选择standalone jar file->点击ok

4)运行->外部工具->外部工具配置->新建配置。

5)为java.exe和selenium Standalone server.jar添加位置和工作目录

6)单击变量并将参数添加为-jar selenium-server-standalone-3.0.1.jar

7)点击应用并运行......

8) 在 Eclipse 控制台中,您将获得端口号,这将确认您启动了 selenium 独立服务器

于 2017-04-24T10:34:47.167 回答
0

启动硒时我遇到了同样的问题。我通过杀死占用端口 4444 的进程解决了这个问题。

  1. netstat -aon | findstr 4444 然后你可以得到pid xx占用4444端口的那个。
  2. taskkill /T /F /pid xx
于 2017-08-11T09:21:14.677 回答