Selenium Grid 4 - how to set up video recording for dynamic grid

3,282 views
Skip to first unread message

Simon Kreß

unread,
May 25, 2021, 1:54:43 AM5/25/21
to Selenium Users
Hello,

I want to set up a dynamic grid with Selenium 4 and use the video recording feature (also view the screen without the vnc plugin, but that is a different topic). I configured everything as described in the Dynamic grid documentation using the hub-node setup and that works fine. Now I want to add video recording for the nodes, but I am struggeling on how to set the capability se:recordVideo. After reading the documentation and searching on the internet how to do this, I could not find out 1) where to set this and 2) what the syntax is to set it. 
I tried to set it in the conf.toml (other options like 'video-image' worked), but recordVideo didn't. Also I looked in the help for the toml file, but there the recordVideo-parameter was not specified. The command for the toml config help is below. 

Toml config help
docker run --rm --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub4 \
    -e SE_EVENT_BUS_PUBLISH_PORT=4442 \
    -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
     -e SE_OPTS=--config-help \
    -v /root/selenium/config.toml:/opt/bin/config.toml \
    -v /root/selenium/assets:/opt/selenium/assets \
    -p 7900:7900 \
    --name selenium-node-debug \
    selenium/node-docker:4.0.0-beta-4-prerelease-20210517

My config.toml file
[docker]
configs = [
    "selenium/standalone-firefox:4.0.0-beta-4-prerelease-20210517", "{\"browserName\": \"firefox\"}",
    "selenium/standalone-chrome:4.0.0-beta-4-prerelease-20210517", "{\"browserName\": \"chrome\"}",
    "selenium/standalone-edge:4.0.0-beta-4-prerelease-20210517", "{\"browserName\": \"MicrosoftEdge\"}"
    ]
assets-path = "/root/selenium/assets/"
container-assets-path = "/opt/selenium/assets"
"se:recordVideo" = "true"


If you need more information please let me know. 

Best regards
Simon Kreß

Diego Molina

unread,
May 28, 2021, 4:17:06 AM5/28/21
to Selenium Users
A code snipped in Java would be:

URL gridUrl = new URL("http://localhost:4444");
ChromeOptions options = new ChromeOptions();
options.setCapability("se:recordVideo", true);
options.setCapability("se:timeZone", "US/Pacific");
options.setCapability("se:screenResolution", "1920x1080");
RemoteWebDriver webDriver = new RemoteWebDriver(gridUrl, options);

Simon Kreß

unread,
May 31, 2021, 7:59:17 AM5/31/21
to Selenium Users
Thank you very much, this worked.

Hasan Naqvi

unread,
Apr 14, 2022, 11:39:13 PM4/14/22
to Selenium Users
Hi! I am struggling to set up Selenium Grid 4 using docker. I think I have followed the documentation but still getting errors as follows. It will be great help to point me right direction.

docker network create grid

 docker-compose up
selenium-hub is up-to-date
Starting seleniumgrid_node-docker_1 ...
Starting seleniumgrid_node-docker_1 ... error

ERROR: for seleniumgrid_node-docker_1  Cannot start service node-docker: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/home/vagrant/selenium_grid/NodeDocker/config.toml" to rootfs at "/opt/bin/config.toml" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

ERROR: for node-docker  Cannot start service node-docker: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/home/vagrant/selenium_grid/NodeDocker/config.toml" to rootfs at "/opt/bin/config.toml" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.




cat config.toml
[docker]
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
    "selenium/standalone-firefox:4.1.3-20220327", "{\"browserName\": \"firefox\"}",
    "selenium/standalone-chrome:4.1.3-20220327", "{\"browserName\": \"chrome\"}",
    "selenium/standalone-edge:4.1.3-20220327", "{\"browserName\": \"MicrosoftEdge\"}"
    ]

# URL for connecting to the docker daemon
# Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
# 127.0.0.1 is used because interally the container uses socat when /var/run/docker.sock is mounted
# If var/run/docker.sock is not mounted:
# Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
# macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
# then use http://host.docker.internal:2375.
# Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
url = "http://127.0.0.1:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-4.3.1-20220327"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
[server]
#host = <ip-from-node-machine>
host = 192.168.0.7
port = 8765


 cat docker-compose.yml
# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3-dynamic-grid.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-dynamic-grid.yml down`
version: "3"
services:
  node-docker:
    image: selenium/node-docker:4.1.3-20220327
    volumes:
      - ./assets:/opt/selenium/assets
      - ./NodeDocker/config.toml:/opt/bin/config.toml
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - selenium-hub
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443

  selenium-hub:
    image: selenium/hub:4.1.3-20220327
    container_name: selenium-hub
    ports:
      - "4442:4442"
      - "4443:4443"
      - "4444:4444"



Reply all
Reply to author
Forward
0 new messages