Unable to Take Screenshots Using Firefox Nodes - selenium

My Selenium tests are designed to take screenshots on failure and add them to the report. The screenshots are displaying perfectly for chrome browsers, but Firefox screenshots are just white rectangles.The changelog says something about a "pass through" mode https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG which I've tried to disable, but nothing seems to be working.
Here's my docker compose file:
seleniumhub:
image: selenium/hub
ports:
- 4444:4444
firefoxnode:
image: selenium/node-firefox-debug
ports:
- 4577
links:
- seleniumhub:hub
environment:
- enablePassThrough=false
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5
chromenode:
image: selenium/node-chrome-debug
ports:
- 4578
links:
- seleniumhub:hub
environment:
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5

I don't think enablePassThrough is a valid environment variable. The configuration is generated from https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeFirefox/generate_config which only contains your NODE_MAX_INSTANCES and NODE_MAX_SESSION.
However, there is a SE_OPTS variable from the parent base image in the entrypoint at https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeBase/entry_point.sh#L28-L30. You can use this to set -enablePassThrough false. Your service definition in Docker Compose would be something like this instead:
firefoxnode:
image: selenium/node-firefox-debug
ports:
- 4577
links:
- seleniumhub:hub
environment:
- SE_OPTS="-enablePassThrough false"
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5

Related

Chrome Node is not registering to Selenium Hub after upgrading to Selenium Grid 4.0.0

We are using a docker-compose file for creating a selenium grid network and after upgrading to selenium grid version 4.0.0 we have found that the grid is not registering to the node.
In this case, we are always receiving the below error.
chrome_1 | 12:18:47.180 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: The hub responded with 404
We tried to revert back to the previous version and found that it is working fine. Can you help us identify why it is not working in Selenium Grid 4? Is there any additional settings required to be done? We tried to find in the Selenium Grid 4 official page, but couldn't find much.
Attaching docker-compose file for reference
version: '3.8'
services:
selenium:
image: selenium/hub
ports:
- 4444:4444
environment:
GRID_MAX_SESSION: 10
chrome:
image: selenium/node-chrome-debug
shm_size: 2gb
depends_on:
- selenium
environment:
- HUB_HOST=selenium
- NODE_MAX_INSTANCES=10
- NODE_MAX_SESSION=10
ports:
- 5901:5900
You need to read the following about all the changes to the grid at the following link: Docker images for the Selenium Grid Server
Your docker-compose.yml file based on the above will now be:
version: '3.8'
services:
selenium:
image: selenium/hub
ports:
- 4442:4442
- 4443:4443
- 4444:4444
chrome:
image: selenium/node-chrome-debug
shm_size: 2gb
depends_on:
- selenium
environment:
- SE_EVENT_BUS_HOST=selenium
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
- SE_NODE_MAX_SESSIONS=10
ports:
- 5901:5900
However, you need to read the full details from the link to ensure you have the correct setup
Check out this example https://github.com/SeleniumHQ/docker-selenium/blob/trunk/docker-compose-v3.yml
I copied the values in that file and it worked for me.
From the docs

How to configure selenoid to use a specific version of selenoid/video-recorder to be used to record session

is there any way to mention which version of selenoid/video-recorder should be used while selenoid is started? either in docker-compose.yml or command line?
I get following error, due to the docker pull limit issue, so I need to mention the specific version i have pulled earlier.
2021/04/08 10:35:59 [909] [5.64s] [SESSION_FAILED] [test] [x.x.x.x] [chrome-89.0] [x.x.x.x:4444] [-] [6] [start video container: create video container: Error response from daemon: No such image: selenoid/video-recorder:latest-release]
Following is my docker compose file.
version: '3'
services:
selenoid:
network_mode: bridge
image: aerokube/selenoid:1.10.1
volumes:
- "/opt/selenoid:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/opt/selenoid/video:/opt/selenoid/video"
environment:
- OVERRIDE_VIDEO_OUTPUT_DIR=/opt/selenium/video
- TZ=America/Montreal
- limit=10
command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video"]
ports:
- "4444:4444"
selenoid-ui:
image: "aerokube/selenoid-ui"
network_mode: bridge
links:
- selenoid
ports:
- "8080:8080"
command: ["--selenoid-uri", "http://selenoid:4444"]
Respective image can be specified with -video-recorder-image flag in in command section. All available flags are listed here: https://aerokube.com/selenoid/latest/#_selenoid_cli_flags

Building your own docker images of SeleniumHQ/docker-selenium

I'm not sure if it is a bug or just me being stupid but here is the case.
I want to build my image based on StandaloneChromeDebug. Following the Wiki:
Pull the repo.
Generate image:
$ make standalone_chrome_debug
Build the Dockerfile to insure that no errors arise:
$ docker build --no-cache etc/docker-selenium/StandaloneChromeDebug/
Set up my image to the docker-compose.yml like:
selenium-hub:
container_name: selenium-hub
build: ./etc/docker-selenium/StandaloneChromeDebug/
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
- "5900:5900"
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
And... nothing. The container is running (no errros) but Selenium doesn't work, container log is empty, /opt/ folder is empty. What am i doing wrong? How to debug the thing?
Path is wrong, use build: /etc/docker-selenium/StandaloneChromeDebug/ without .
If you try to cd to ./etc/docker-selenium/StandaloneChromeDebug/, you will get an error.
version: "3.5"
services:
selenium-hub:
container_name: selenium-hub
build: /etc/docker-selenium/StandaloneChromeDebug/
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
- "5900:5900"
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
Exapmle:
I feel you are using "build" tag in your compose file rather than "image". Please use "image" tag instead and see if that runs your image correctly.
Also can you please show how you are launching your docker services and what the output is?
Reference to build command

Docker-The scale command is deprecated. Use the up command with the --scale flag instead

i want to launch 5 chrome and 5 firefox in docker container. I am using the below command but its giving the following error
The scale command is deprecated. Use the up command with the --scale flag instead.
ERROR: No such service: nodechrome
docker-compose scale nodechrome=5 nodefirefox=5
My docker-compose.yml file
version: '2'
services:
firefoxnode:
image: selenium/node-firefox-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32772:5900"
chromenode:
image: selenium/node-chrome-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32773:5900"
hub:
image: selenium/hub
ports:
- "4444:4444"
From where these names came? nodechrome and nodefirefox
Correct your command instead:
from:
docker-compose scale nodechrome=5 nodefirefox=5
to:
docker-compose scale chromenode=5 firefoxnode=5
Try this command:
docker-compose up --scale chrome=5
Verify the Grid by visiting: http://localhost:4444/ui/index.html#/
Refer: Documentation

change selenium hub default port docker-compose

I have multiple jenkins jobs, each attempt to start a selenium standalone container, although when multiple jobs run in parallel in the same jenkins slave, it throws the following error:
0.0.0.0:4444 failed: port is already allocated
Which is fair enough because the default port for the selenium standalone is set to 4444. My question is how I override the selenium standalone port? I thought it was related to ports: ... but clearly not... any ideas?
Below is my docker-compose file:
maven:
build: "."
links:
- "selenium:selenium"
working_dir: /code/
volumes:
- ".:/code"
entrypoint:
- mvn
- verify
- -Dwebdriver.remote.url=http://selenium:4444/wd/hub
selenium:
image: selenium/standalone-chrome:latest
ports:
- "4444:4444"
I have for instance another docker-compose file, slightly different, for instance:
maven_2:
build: "."
links:
- "selenium_2:selenium_2"
working_dir: /code/
volumes:
- ".:/code"
entrypoint:
- mvn
- verify
- -Dsome.additional.tags=test
- -Dwebdriver.remote.url=http://selenium_2:4444/wd/hub
selenium_2:
image: selenium/standalone-chrome:latest
ports:
- "4444:4444"