首页 > 解决方案 > Selenium/hub 在 network_mode = "host" 时无法识别 selenium/node-chrome-debug

问题描述

我使用 Docker 在 network_mode = "host" 中启动我的 Selenium 网格,以便我可以访问我的本地开发站点。

集线器和节点都启动了,但是当我检查http://localhost:4444/grid/console时,没有节点。我想知道是否有任何方法可以解决它。

更多信息:

我的码头工人撰写文件:

version: "3"
services:
  selenium-hub:
    image: selenium/hub:latest
    container_name: selenium-hub
    network_mode: "host"
    ports:
      - "4444:4444"
  chrome:
    image: selenium/node-chrome-debug:latest
    depends_on:
      - selenium-hub
    network_mode: "host"
    ports:
      - "5900:5900"
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

标签: seleniumdockerselenium-grid

解决方案


Diego Molina弄清楚了为什么它不起作用。

这是因为 Chrome 容器会尝试注册到 name selenium-hub,该 name 不存在于“host”网络中,并且只会存在于 docker-compose 创建的网络中。

要使其正常工作,只需设置HUB_HOST=localhost.


推荐阅读