I use Selenium IDE for file downloading test. The test works correctly when I ran it locally(downloads page opens and the list contains file that I downloaded), but it doesn't work in robcherry/docker-chromedriver docker. In the test I open chrome://downloads/ page after file downloading and this list is empty in docker.
I've added downloading path to a docker-compose file, but it doesn't help.
Here my docker-compose file
version: '3'
services:
chromedriver:
image: robcherry/docker-chromedriver
privileged: true
restart: always
environment:
- TZ=Europe/Moscow
- CHROMEDRIVER_WHITELISTED_IPS=''
volumes:
- './module-selenium:/selenium'
- './module-selenium/Downloads:/tmp/downloads'
selenium-side-runner:
image: bolotoff/selenium:v11
volumes:
- './module-selenium:/sides'
- './out:/root/out'
Related
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
I am trying to execute my selenium test on Jenkins node (Ubuntu) which has docker already installed. I added docker-compose build step plugin to my Jenkins project. When i try to build the project, I am getting an error in console -
$ docker-compose -f /home/jenkins/workspace/OM/TestWDM/docker-compose.yml up -d
Build step 'Docker Compose Build Step' changed build result to FAILURE
I am able to execute the project successfully on my local machine. I do have docker-compose.yml file in the root directory. I tried docker ps -a command just to see if it's partially . working, but it's not.
docker-compose file:
version: "3"
services:
selenium-hub:
restart: always
image: selenium/hub:latest
ports:
- "4444:4444"
#selenium-chrome
selenium-chrome:
restart: always
image: selenium/node-chrome-debug
stdin_open: true
links:
- selenium-hub:hub
#selenium-firefox
selenium-firefox:
restart: always
image: selenium/node-firefox-debug
links:
- selenium-hub:hub
chrome:
image: selenium/node-chrome
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
firefox:
image: selenium/node-firefox
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
The reason I am trying to use docker here because I was facing an issue with chrome binary not found without it. My expectation over here was to have my test run successfully on Jenkins node.
I have reports generated in gradle container for my selenium tests, I am trying to copy the files from docker container to local host. As a work around, I have used docker cp to copy files from container to my local and it works. How to achieve it with docker-compose volumes.
Below is my docker-compose.yml
version: "3 "
services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub_compose
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome-debug
container_name: selenium-chrome
depends_on:
- selenium-hub
ports:
- "5900"
environment:
- http_proxy=http://x.x.x.x:83
- https_proxy=http://x.x.x.x:83
- HUB_HOST=selenium-hub
- HUB_PORT=4444
gradle:
image: gradle:jdk8
container_name: selenium-gradle
build:
context: .
dockerfile: dockerfile
I run the command docker-compose up -> it runs the selenium tests and generates the report in the container.
Can anyone help on this?
The normal way to pass data from container to host is using docker volumes.
In short you specify a host directory and map it to the directory inside container. And that directory should be used to save your test reports
services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub_compose
ports:
- "4444:4444"
volumes:
- ./path/to/report/folder:/host/reports
See docker documentation
https://docs.docker.com/compose/compose-file/#/volumes-volumedriver
Similar question:
How do I mount a host directory as a volume in docker compose
Power off the machine in Virtual box -> Change the Advanced settings in Virtual box
Goto Shared Folders in Virtual box
Give Path :: C:\DockerResults : Give a logical name for the Folder name
Restart the machine in DockerTerminal with the below command
docker-machine restart default
After machine is started open the Virtual box
Create a directory in the Virtual machine : sudo mkdir /Results
Mount the directory to the local windows machine by executing the below command in virtual box:
Sudo mount –t vboxsf DockerResults /Results
Add volumes as below in docker-compose file
volumes:
- /DockerResults:/home/Reports/
I am unable to copy a file generated by my Selenium tests in a folder inside docker container mounted to host machine.
Here is how my compose file look like
selenium:
image: 'selenium/standalone-chrome'
expose:
- "4444"
tests:
build:
context: ./tests
dockerfile: Dockerfile
depends_on:
- selenium
- web
volumes:
- /testResultsReport:/testResultsReport
This is how my directory structure looks like.
\
- docker-compose.yml
- build scripts
- tests
- testResultsReport
- Test scripts
Name of the file generated inside testResultsReport folder when running docker-compose is TestResultsReport.HTML
As my tests are running inside selenium server on port 4444, should I mount my volume there? I tried doing that to but still not getting my html file copied to host machine?
I confirmed that my html file is generated when i run my tests outside compose.
I also tried ./testResultsReport however it added a folder in root with name of testResultsReport and did nothing. So I used ./tests/testResultsReport but still not getting file.
Worked by using right folder and absolute path. Thanks #chrisz
selenium:
image: 'selenium/standalone-chrome'
expose:
- "4444"
tests:
build:
context: ./tests
dockerfile: Dockerfile
depends_on:
- selenium
- web
volumes:
- ./tests/testResultsReport:/tests/testResultsReport
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"