问题
I am trying to start a Selenium server in the command line, but it returns the following message:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\a607270>java -jar selenium-server-standalone-3.4.0.jar -role hub
09:49:50.198 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
09:49:50.199 INFO - Launching Selenium Grid hub
2017-05-30 09:49:52.134:INFO::main: Logging initialized @2625ms to org.seleniumh
q.jetty9.util.log.StdErrLog
09:49:52.167 INFO - Will listen on 4444
2017-05-30 09:49:52.276:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-05-30 09:49:52.313:INFO:osjs.session:main: DefaultSessionIdManager workerNa
me=node0
2017-05-30 09:49:52.313:INFO:osjs.session:main: No SessionScavenger set, using d
efaults
2017-05-30 09:49:52.320:INFO:osjs.session:main: Scavenging every 660000ms
2017-05-30 09:49:52.364:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletC
ontextHandler@5e955596{/,null,AVAILABLE}
Usage: <main class> [options]
Options:
--version, -version
Displays the version and exits.
Default: false
-browserTimeout
<Integer> in seconds : number of seconds a browser session is allowed to
hang while a WebDriver command is running (example: driver.get(url)). If
the
timeout is reached while a WebDriver command is still processing, the ses
sion
will quit. Minimum value is 60. An unspecified, zero, or negative value m
eans
wait indefinitely.
Default: 0
-matcher, -capabilityMatcher
<String> class name : a class implementing the CapabilityMatcher
interface. Specifies the logic the hub will follow to define whether a re
quest can
be assigned to a node. For example, if you want to have the matching proc
ess
use regular expressions instead of exact match when specifying browser
version. ALL nodes of a grid ecosystem would then use the same capability
Matcher,
as defined here.
Default: org.openqa.grid.internal.utils.DefaultCapabilityMatcher@3439f68d
-cleanUpCycle
<Integer> in ms : specifies how often the hub will poll running proxies
for timed-out (i.e. hung) threads. Must also specify "timeout" option
Default: 5000
-custom
<String> : comma separated key=value pairs for custom grid extensions.
NOT RECOMMENDED -- may be deprecated in a future revision. Example: -cust
om
myParamA=Value1,myParamB=Value2
Default: {}
-debug
<Boolean> : enables LogLevel.FINE.
Default: false
-host
<String> IP or hostname : usually determined automatically. Most commonly
useful in exotic network configurations (e.g. network with VPN)
Default: 10.56.130.102
-hubConfig
<String> filename: a JSON file (following grid2 format), which defines
the hub properties
-jettyThreads, -jettyMaxThreads
<Integer> : max number of threads for Jetty. An unspecified, zero, or
negative value means the Jetty default value (200) will be used.
-log
<String> filename : the filename to use for logging. If omitted, will log
to STDOUT
-maxSession
<Integer> max number of tests that can run at the same time on the node,
irrespective of the browser used
-newSessionWaitTimeout
<Integer> in ms : The time after which a new test waiting for a node to
become available will time out. When that happens, the test will throw an
exception before attempting to start a browser. An unspecified, zero, or
negative
value means wait indefinitely.
Default: -1
-port
<Integer> : the port number the server will use.
Default: 4444
-prioritizer
<String> class name : a class implementing the Prioritizer interface.
Specify a custom Prioritizer if you want to sort the order in which new s
ession
requests are processed when there is a queue. Default to null ( no priori
ty = FIFO
)
-role
<String> options are [hub], [node], or [standalone].
Default: hub
-servlet, -servlets
<String> : list of extra servlets the grid (hub or node) will make
available. Specify multiple on the command line: -servlet tld.company.Ser
vletA
-servlet tld.company.ServletB. The servlet must exist in the path:
/grid/admin/ServletA /grid/admin/ServletB
Default: []
-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: 1800
-throwOnCapabilityNotPresent
<Boolean> true or false : If true, the hub will reject all test requests
if no compatible proxy is currently registered. If set to false, the requ
est
will queue until a node supporting the capability is registered with the
grid.
Default: true
-withoutServlet, -withoutServlets
<String> : list of default (hub or node) servlets to disable. Advanced
use cases only. Not all default servlets can be disabled. Specify multipl
e on
the command line: -withoutServlet tld.company.ServletA -withoutServlet
tld.company.ServletB
Default: []
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:298)
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:431)
at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(Abstract
LifeCycle.java:68)
at org.openqa.grid.web.Hub.start(Hub.java:184)
at org.openqa.grid.selenium.GridLauncherV3$2.launch(GridLauncherV3.java:
259)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:99)
Can anyone help me resolve this issue? If more information is needed, I can provide it.
I am using Windows 7 Professional, and am working in a corporate setting, so there may be proxy issues.
回答1:
Here is the Answer to your Question:
It's quite clear from the error logs java.net.BindException: Address already in use: bind
that the default port 4444
on which Selenium Grid Hub
listens is in use by some other application. So you can consider using some other port for Selenium Grid Hub
as follows:
C:\Users>java -jar C:\Utility\selenium-server-standalone\selenium-server-standalone-3.4.0.jar -role hub -port 5786
You can access the Selenium Grid Server console through http://localhost:5786/grid/console
Let me know if this Answers your Question.
来源:https://stackoverflow.com/questions/44262919/selenium-server-setup-errors