I'm attempting to record a video from a Selenium test and so far, it's not working.
selenium-video
container's log window isn't showing any issues nor is it showing feedback of processing test results.I'm using PHPUnit under CakePHP.
My Docker configuration:
selenium:
container_name: selenium
image: selenium/standalone-edge:latest
shm_size: 2gb
networks:
- frontend
- backend
ports:
- "4444:4444"
- "7900:7900"
environment:
TZ: ${TIMEZONE}
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
LANGUAGE: en_US.UTF-8
volumes:
- "$LOCAL_FOLDER:/mnt/local_folder"
selenium-video:
container_name: selenium-video
image: selenium/video:ffmpeg-7.1-20250123
networks:
- frontend
- backend
environment:
- DISPLAY_CONTAINER_NAME=selenium
- SE_NODE_GRID_URL=http://selenium:4444
# - FILE_NAME=chrome_video.mp4
- SE_VIDEO_FILE_NAME=auto
volumes:
- "$LOCAL_FOLDER:/videos"
Inspiration: https://github.com/SeleniumHQ/docker-selenium/blob/trunk/docker-compose-v3-video.yml
Edit: perhaps it's container standalone-edge
vs. node-edge
issue?
Solution
I was missing environment variables, essentially (ie. SE_NODE_PORT
and SE_VIDEO_RECORD_STANDALONE
).
selenium-video:
container_name: selenium-video
image: selenium/video:ffmpeg-7.1-20250123
networks:
- frontend
- backend
environment:
- DISPLAY_CONTAINER_NAME=selenium
- SE_NODE_GRID_URL=http://selenium:4444
# - FILE_NAME=chrome_video.mp4
- SE_VIDEO_FILE_NAME=auto
- SE_NODE_PORT=4444
- SE_VIDEO_RECORD_STANDALONE=true
volumes:
- "$LOCAL_FOLDER:/videos"
Also need the following configured client, particularly the se:recordVideo
to control video capture
// Start a browser session
$capabilities = DesiredCapabilities::microsoftEdge();
$chrome_options = (new ChromeOptions)->addArguments(['--lang' => 'en']);
//set language
$capabilities->setCapability('goog:chromeOptions', $chrome_options);
// Set the options in the capabilities
$capabilities->setCapability('platformName', 'linux');
$capabilities->setCapability('se:name', basename(__FILE__, '.php'));//video prefix, session gets appended
$capabilities->setCapability('se:recordVideo', 'false');//may not want to record every test
$capabilities->setCapability('se:screenResolution', '1920x1080');//resolution
$this->driver = RemoteWebDriver::create('http://selenium:4444/wd/hub', $capabilities);
Did you set the capability on the client? options = ChromeOptions() options.set_capability('se:recordVideo', True)