- Step 6 :启动 hub/node 模式(一个hub 下挂多个node)
- 启动hub
java -jar selenium-server-4.6.0.jar hub --host 0.0.0.0 --port 4444 --log /export/selena/logs/SeleniumGrid/gridLog.log &
hub : 启动hub
--host : hub的IP地址,IP公开访问就写 0.0.0.0
--port : hub的端口号;默认端口是4444,可以改
--log : 把日志写到指定路径指定文件
启动日志
10:35:17.318 INFO [LogManager$RootLogger.log] - Using the system default encoding
10:35:17.322 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
10:35:17.404 INFO [BoundZmqEventBus.<init>] - XPUB binding to [binding to tcp://*:4442, advertising as tcp://11.158.11.150:4442], XSUB binding to [binding to tcp://*:4443, advertising as tcp://11.158.11.150:4443]
10:35:17.447 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://11.158.11.150:4442 and tcp://11.158.11.150:4443
10:35:17.467 INFO [UnboundZmqEventBus.<init>] - Sockets created
10:35:18.468 INFO [UnboundZmqEventBus.<init>] - Event bus ready
10:35:19.056 INFO [Hub.execute] - Started Selenium Hub 4.6.0 (revision 79f1c02ae20): http://0.0.0.0:4444
10:35:28.583 INFO [Node.<init>] - Binding additional locator mechanisms: relative, name, id
10:35:29.037 INFO [GridModel.setAvailability] - Switching Node 41412e8f-4c84-4beb-92d9-0145f08a3dd1 (uri: http://11.158.11.150:5555) from DOWN to UP
10:35:29.038 INFO [LocalDistributor.add] - Added node 41412e8f-4c84-4beb-92d9-0145f08a3dd1 at http://11.158.11.150:5555. Health check every 120s
- 启动node
java -jar selenium-server-4.6.0.jar node --hub http://localhost:4444 --port 5555 --log /export/selena/logs/SeleniumGrid/node.log &
node : 启动node节点
--hub : hub的ip地址和端口号;这里我们在同一台机器启动可以写localhost/127.0.0.1
--port : node的端口号;这里默认端口是5555,可以改
--log : 把日志写到指定路径指定文件
启动日志
10:35:27.041 INFO [LogManager$RootLogger.log] - Using the system default encoding
10:35:27.044 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
10:35:27.146 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://localhost:4442 and tcp://localhost:4443
10:35:27.188 INFO [UnboundZmqEventBus.<init>] - Sockets created
10:35:28.190 INFO [UnboundZmqEventBus.<init>] - Event bus ready
10:35:28.251 INFO [NodeServer.createHandlers] - Reporting self as: http://11.158.11.150:5555
10:35:28.265 INFO [NodeOptions.getSessionFactories] - Detected 4 available processors
10:35:28.314 WARN [DriverService.findExecutable] - Unable to obtain driver using Selenium Manager: Error running command: [/tmp/selenium-manager11050479037956957992126718683351748/selenium-manager, --driver, msedgedriver]
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-1.el8.jd_606.x86_64', java.version: '1.8.0_271'
Driver info: driver.version: unknown
10:35:28.316 WARN [DriverService.findExecutable] - Unable to obtain driver using Selenium Manager: Error running command: [/tmp/selenium-manager11050479037956957992126718683351748/selenium-manager, --driver, geckodriver]
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-1.el8.jd_606.x86_64', java.version: '1.8.0_271'
Driver info: driver.version: unknown
10:35:28.318 INFO [NodeOptions.discoverDrivers] - Discovered 1 driver(s)
10:35:28.345 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 4 times
10:35:28.356 INFO [Node.<init>] - Binding additional locator mechanisms: name, relative, id
10:35:28.519 INFO [NodeServer$1.start] - Starting registration process for Node http://11.158.11.150:5555
10:35:28.520 INFO [NodeServer.execute] - Started Selenium node 4.6.0 (revision 79f1c02ae20): http://11.158.11.150:5555
10:35:28.536 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
10:35:29.048 INFO [NodeServer.lambda$createHandlers$2] - Node has been added
支持参数的帮助说明
Usage: node [options]
Options:
--allow-cors
Whether the Selenium server should allow web browser connections from
any host
Default: false
--bind-bus
Whether the connection string should be bound or connected. When true,
the component will be bound to the Event Bus (as in the Event Bus will
also be started by the component, typically by the Distributor and the
Hub). When false, the component will connect to the Event Bus.
--bind-host
Whether the server should bind to the host address/name, or only use it
to report its reachable url. Helpful in complex network topologies where
the server cannot report itself with the current IP/hostname but rather
an external IP or hostname (e.g. inside a Docker container).
Default: true
--config
Config file to read from (may be specified more than once)
--config-help
Output detailed information about config options
Default: false
--detect-drivers
Autodetect which drivers are available on the current system, and add
them to the Node.
Default: true
--docker, -D
Docker configs which map image name to stereotype capabilities (example:
-D selenium/standalone-firefox:latest '{"browserName": "firefox"}')
--docker-assets-path
Absolute path where assets will be stored
--docker-devices
Exposes devices to a container. Each device mapping declaration must
have at least the path of the device in both host and container
separated by a colon like in this example:
/device/path/in/host:/device/path/in/container
--docker-host
Host name where the docker daemon is running
--docker-port
Port where the docker daemon is running
--docker-url
URL for connecting to the docker daemon
--docker-video-image
Docker image to be used when video recording is enabled
Default: selenium/video:latest
--drain-after-session-count
Drain and shutdown the Node after X sessions have been executed. Useful
for environments like Kubernetes. A value higher than zero enables this
feature.
Default: 0
--driver-configuration
List of configured drivers a Node supports. It is recommended to provide
this type of configuration through a toml config file to improve
readability. Command line example: --drivers-configuration
display-name="Firefox Nightly" max-sessions=2
webdriver-path="/usr/local/bin/geckodriver" stereotype='{"browserName":
"firefox", "browserVersion": "86", "moz:firefoxOptions":
{"binary":"/Applications/Firefox
Nightly.app/Contents/MacOS/firefox-bin"}}'
--driver-factory
Mapping of fully qualified class name to a browser configuration that
this matches against. --driver-factory
org.openqa.selenium.example.LynxDriverFactory '{"browserName": "lynx"}'
-I, --driver-implementation
Drivers that should be checked. If specified, will skip
autoconfiguration. Example: -I "firefox" -I "chrome"
Default: []
--enable-bidi
Enable BiDi proxying in Grid. A Grid admin can disable BiDi if the
network does not allow websockets. True by default
Default: true
--enable-cdp
Enable CDP proxying in Grid. A Grid admin can disable CDP if the network
does not allow websockets. True by default
Default: true
--events-implementation
Full classname of non-default event bus implementation
--grid-url
Public URL of the Grid as a whole (typically the address of the Hub or
the Router)
--heartbeat-period
How often, in seconds, will the Node send heartbeat events to the
Distributor to inform it that the Node is up.
Default: 60
--host
Server IP or hostname: usually determined automatically.
--http-logs
Enable http logging. Tracing should be enabled to log http logs.
Default: false
--https-certificate
Server certificate for https. Get more detailed information by running
"java -jar selenium-server.jar info security"
--https-private-key
Private key for https. Get more detailed information by running "java
-jar selenium-server.jar info security"
--hub
The address of the Hub in a Hub-and-Node configuration. This can be a
plain hostname or IP address (`hostname`), in which case the Hub will be
assumed to be `http://hostname:4444`, the `--grid-url` will be the same,
`--publish-events` will be `tcp://hostname:4442` and
`--subscribe-events` will be `tcp://hostname:4443`. If `hostname`
contains a port number, that will be used for `--grid-url` but the URIs
for the event bus will remain the same. Any of these default values may
be overridden but setting the correct flags. If the hostname has a
protocol (such as `https`) that will be used too.
--log
File to write out logs. Ensure the file path is compatible with the
operating system's file path. Windows path example:
\\path\to\file\gridlog.log OR C:\path\path\to\file\gridlog.log
Linux/Unix/MacOS path example: /path/to/file/gridlog.log
--log-encoding
Log encoding
--log-level
Log level. Default logging level is INFO. Log levels are described here
https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html
Default: INFO
--log-timestamp-format
Format of the timestamp in log output
--max-sessions
Maximum number of concurrent sessions. Default value is the number of
available processors.
Default: 4
--max-threads
Maximum number of listener threads. Default value is: (available
processors) * 3.
Default: 0
--no-vnc-port
If VNC is available, sets the port where the local noVNC stream can be
obtained
Default: 7900
--node-implementation
Full classname of non-default Node implementation. This is used to
manage a session's lifecycle.
Default: org.openqa.selenium.grid.node.local.LocalNodeFactory
--override-max-sessions
The # of available processors is the recommended max sessions value (1
browser session per processor). Setting this flag to true allows the
recommended max value to be overwritten. Session stability and
reliability might suffer as the host could run out of resources.
Default: false
--plain-logs
Use plain log lines
Default: true
-p, --port
Port to listen on. There is no default as this parameter is used by
different components, for example Router/Hub/Standalone will use 4444
and Node will use 5555.
--publish-events
Connection string for publishing events to the event bus
--register-cycle
How often, in seconds, the Node will try to register itself for the
first time to the Distributor.
Default: 10
--register-period
How long, in seconds, will the Node try to register to the Distributor
for the first time. After this period is completed, the Node will not
attempt to register again.
Default: 120
--registration-secret
Node registration secret
--service-configuration
Configuration for the service where calls will be relayed to. It is
recommended to provide this type of configuration through a toml config
file to improve readability. Command line example:
--service-configuration max-sessions=2 stereotype='{"browserName":
"safari", "platformName": "iOS", "appium:platformVersion": "14.5"}}'
--service-host
Host name where the service that supports WebDriver commands is running
--service-port
Port where the service that supports WebDriver commands is running
--service-status-endpoint
Endpoint to query the WebDriver service status, an HTTP 200 response is
expected
--service-url
URL for connecting to the service that supports WebDriver commands, like
an Appium server or a cloud service.
--session-timeout
Let X be the session-timeout in seconds. The Node will automatically
kill a session that has not had any activity in the last X seconds. This
will release the slot for other tests.
Default: 300
--structured-logs
Use structured logs
Default: false
--subscribe-events
Connection string for subscribing to events from the event bus
--tracing
Enable trace collection
Default: true
--version
Displays the version and exits.
Default: false
--vnc-env-var
Environment variable to check in order to determine if a vnc stream is
available or not.
Default: SE_START_XVFB
启动后的截图