Selenium 4.x Grid 2/4 hub/node 模式

  • 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

启动后的截图


image.png
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,014评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,796评论 3 386
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,484评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,830评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,946评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,114评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,182评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,927评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,369评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,678评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,832评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,533评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,166评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,885评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,128评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,659评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,738评论 2 351

推荐阅读更多精彩内容