Skip to content

💻 Selenium Hub (Chrome and Firefox)

Renan Altendorf edited this page Feb 8, 2025 · 1 revision

Selenium integration allows you to process websites that require javascript or have some more advanced protection barriers. To use this functionality, you need to set up a Selenium environment with Firefox. Add the following configuration to your docker-compose.yml:

services:
  selenium-firefox:
    container_name: selenium-firefox
    image: selenium/node-firefox:4.27.0-20241204
    shm_size: 2gb
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
      - SE_ENABLE_TRACING=false
      - SE_NODE_MAX_SESSIONS=10
      - SE_NODE_OVERRIDE_MAX_SESSIONS=true
    entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh'
    depends_on:
      - selenium-hub

  selenium-hub:
    image: selenium/hub:4.27.0-20241204
    container_name: selenium-hub
    environment:
      - SE_ENABLE_TRACING=false
      - GRID_MAX_SESSION=10
      - GRID_BROWSER_TIMEOUT=10
      - GRID_TIMEOUT=10
    ports:
      - 4442:4442
      - 4443:4443
      - 4444:4444
  • shm_size: Sets the size of the shared memory for Firefox (2GB recommended)
  • SE_NODE_MAX_SESSIONS: Maximum number of concurrent sessions per node
  • GRID_MAX_SESSION: Maximum number of concurrent sessions on the hub
  • GRID_BROWSER_TIMEOUT and GRID_TIMEOUT: Timeouts in seconds

After configuring Selenium, make sure to set the SELENIUM_HOST variable in your environment to point to the Selenium hub (usually selenium-hub:4444).

Clone this wiki locally