1

我目前正在尝试在端口 6900 的 docker-compose 上运行 Selenium Remote 驱动程序,版本selenium==4.0.0b2.post1 。

我目前可以连接到 selenium 网格,但我无法运行远程 webdriver。

我的 dockerfile 是:

# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3.yml up`
# Add the `-d` flag at the end for detached execution
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down`
version: "3"
services:
  chrome:
    image: selenium/node-chrome:4.0.0-beta-3-prerelease-20210319
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    ports:
      - "6900:5900"

  selenium-hub:
    image: selenium/hub:4.0.0-beta-3-prerelease-20210319
    container_name: selenium-hub
    ports:
      - "4442:4442"
      - "4443:4443"
      - "4444:4444"
    environment:
      - JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=

我正在尝试使用以下代码连接到 Selenium:重要提示:selenium 版本是 4.0.0b2.post1,我可以使其与 selenium 3.1 一起使用......但我需要一些 SE4 功能

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver


driver = webdriver.Remote(
    command_executor='http://localhost:4444/wd/hub',
    desired_capabilities=DesiredCapabilities.CHROME
)

driver.get('http://www.google.com/')

请注意,我在 docker 控制台中得到的错误如下:

INFO [Distributor.newSession] - Session created by the distributor. Id: e9616d2cad52fwerwefbab0c4b09f08, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 89.0.4389.90, chrome: {chromedriverVersion: 89.0.4389.23 (61b08ee2c5002..., userDataDir: /tmp/.com.google.Chrome.4fUoUu}, goog:chromeOptions: {debuggerAddress: localhost:42915}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: {}, se:cdp: http://172.23.0.3:5555/sess..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
4

0 回答 0