How do you set up selenium grid using docker on windows? - selenium

Steps I have taken already
1. Downloaded and installed Docker Toolbox for windows
2. Open Docker Quickstart terminal
3. Entered the below commands to pull the docker images from dockerhub and run them
docker pull selenium/hub
docker pull selenium/node-chrome
docker pull selenium/node-firefox
docker run -d -P \--name hub selenium/hub
docker run -d --link hub:hub -P \--name chrome selenium/node-chrome
docker run -d --link hub:hub -P \--name firefox selenium/node-firefox
It appears to be running when I type docker logs hub but I am unable to route my tests to the hub's address on the virtualbox VM using seleniumAddress in my conf.js file or see it using http://ipAddress:4444/grid/console .
Ideally I would like to use this set up to expand the amount of parallel test instances I can run.

Unfortunately the selenium docker image might be broken since 4 days ago but you can try my alternative one:
Pull the image and run as many containers as you need
docker pull elgalu/selenium
docker run -d --name=grid4 -p 4444:24444 -p 5904:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium
docker run -d --name=grid5 -p 4445:24444 -p 5905:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium
docker run -d --name=grid6 -p 4446:24444 -p 5906:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium
Wait until the all the grids started properly before starting the tests (Optional but recommended)
docker exec grid4 wait_all_done 30s
docker exec grid5 wait_all_done 30s
docker exec grid6 wait_all_done 30s
After this, Selenium should be up and running at http://localhost:4444/wd/hub. Open the url in your browser to confirm it is running.
If you are using Mac (OSX) or Microsoft Windows localhost won't work! Find out the correct IP through boot2docker ip or docker-machine ip default.
So set the selenium port accordingly for each of your test:
1st test should connect to http://ipAddress:4444/wd/hub
2nd test to http://ipAddress:4445/wd/hub
3rd test to http://ipAddress:4446/wd/hub
You can run as many as your hardware can take.

Take a look at the Protractor Cookbook w/ Docker. The instructions are listed step-by-step using selenium-grid and docker compose. Docker-selenium issue #208 has been fixed.
So you'll need to pull down the latest images*:
docker pull selenium/hub:latest
docker pull selenium/node-chrome-debug:latest
Start the selenium grid:
docker run -d -p 4444:4444 --name selenium-hub selenium/hub:latest
Then add selenium nodes. I like to use the chrome-debug and firefox-debug versions to VNC to watch the tests.
docker run -d -p <port>:5900 --link selenium-hub:hub selenium/node-chrome-debug:latest
After linking your selenium grid, this should be enough to run your Protractor test using the seleniumAddress: 'http://localhost:4444/wd/hub'.
For debugging, find the VNC port for the container with:
docker port <container-name or container-id> 5900
and access it via VNC Viewer.
Note:
At the time of this writing, 'latest' appears to be tied to a ~2.53.1 version of selenium server. As of Protractor 4.0.11 (the latest version of Protractor), this is the supported version that should be used. Note that the instructions on the Selenium-docker GitHub appear to be for tailored for selenium server 3.0.1.

You can use below compose file to setup grid and access via VNC
**# To execute this docker-compose yml file use docker-compose -f up
**# Add the "-d" flag at the end for deattached execution****
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"
command I use:
docker-compose -f .\docker-compose.yml up -d
Source :
https://github.com/SeleniumHQ/docker-selenium

Related

Issue connection Selenoid GGR (Go Grid Router)

I am trying to run nightwatchjs test using selenoid ggr (Go Grid router) but I am getting the below error:
- Connecting to un:pwd#ip_add on port 4444...
POST http://un:pwd#ip_add:4444 /wd/hub/session - EAI_FAIL
Error: getaddrinfo EAI_FAIL un:pwd#ip_add
‼ Error connecting to un:pwd#ip_add on port 4444.
Below are the various container that's running on my Linux machine (IP_add)
Could you please support in identifying the issue?
Also, I am unable to navigate to ggr-ui
I was now able to run the test using GGR.
Following command were run to start selenoid, ggr, ggr-ui and selenoid UI:
./cm selenoid start --vnc --port 4445
docker run -d --name ggr -v /etc/grid-router/:/etc/grid-router:ro --net host aerokube/ggr:latest-release
docker run -d --name ggr-ui -p 8888:8888 -v /etc/grid-router/quota/:/etc/grid-router/quota:ro aerokube/ggr-ui:latest-release
docker run -d --name selenoid-ui --link ggr-ui -p 8080:8080 aerokube/selenoid-ui --selenoid-uri=http://ggr-ui:8888
To navigate to ggr dashboard:
http://'ip address':8080/
In nightwatch config use following selenoum config:
host: '192.168.5.241',
port: 4444,
'username': "test",
'access_key': "test-password",
start_process: false,
This way I was able to run the test
Well, to run tests on GGR for me was enough official documentations
https://aerokube.com/ggr/latest/
I configured 2 machines
On machine №1 (where was configure ggr + ggr(ui))
You can see my list of configured containers
list of containers screen
On machine №2
Was configured Selenoid and Selenoid UI
Also do not forget to configure quota file(see official documentation)
See common screen of configuration:
screen of common configuration

How to make Zalenium work with AWS Fargate?

The issue
I would like to use Zalenium in a container using AWS Fargate. However, to do so, we have to pull two images: Zalenium and Selenium. Indeed, during its process, Zalenium creates containers using Selenium image. Therefore it needs to find the Image somewhere.
A possible solution
I was thinking of creating an ubuntu container with Docker installed which would run the following commands:
It would first pull the images
docker pull elgalu/selenium
docker pull dosel/zalenium
and then create a Zalenium container with the Docker socket mounted to create another container:
docker run --rm -ti --name zalenium -p 4444:4444 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos:/home/seluser/videos \
--privileged dosel/zalenium start
That would mean I would create a container that would inside another container that would be inside another container which doesn't sound straightforward.
So before doing that, I wanted to check if someone wouldn't have a better solution. As being new to AWS, I might have missed something.
You can pull the image implicity through the Zalenium container, just check https://opensource.zalando.com/zalenium/#tryit, section "Or without pulling elgalu/selenium explicitly:"
Example:
# Pull Zalenium
docker pull dosel/zalenium
# Run it!
docker run --rm -ti --name zalenium -p 4444:4444 \
-e PULL_SELENIUM_IMAGE=true \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos:/home/seluser/videos \
--privileged dosel/zalenium start
# Point your tests to http://localhost:4444/wd/hub and run them
# Stop
docker stop zalenium

How to point RemoteWebDriver to one of the multiple standalone docker selenium standalone chrome browsers?

I've requirement to run test cases on separate chrome browsers running inside docker container.
I've install chrome docker containers as below
docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
docker run -d -p 4444:4444 -p 5901:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
I have scripts which does unique tasks like analytics testing, performance testing etc so I can't use Grid approach here.
This is what I do in case of single chrome browser but I need to point to a particular docker container image
WebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox());
Got it working with help of comment from #Flore B.
docker run -d -p 5902:4444 -p 5903:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
RemoteWebDriver url
http://0.0.0.0:5902/wd/hub

AMC for the aerospike server running inside docker

I have run the aerospike server inside docker container using below command.
$ docker run -d -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 -p 8081:8081 --name aerospike aerospike/aerospike-server
89b29f48c6bce29045ea0d9b033cd152956af6d7d76a9f8ec650067350cbc906
It is running succesfully. I verified it using the below command.
$ docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
89b29f48c6bc aerospike/aerospike-server "/entrypoint.sh asd"
About a minute ago Up About a minute 0.0.0.0:3000-3003->3000-3003/tcp, 0.0.0.0:8081->8081/tcp aerospike
I'm able to successfully connect it with aql.
$ aql
Aerospike Query Client
Version 3.13.0.1
C Client Version 4.1.6
Copyright 2012-2016 Aerospike. All rights reserved.
aql>
But when I launch the AMC for aerospike server in docker, it is hanging and it is not displaying any data. I've attached the screenshot.
Did I miss any configuration. Why it is not loading any data?
You can try the following:
version: "3.9"
services:
aerospike:
image: "aerospike:ce-6.0.0.1"
environment:
NAMESPACE: testns
ports:
- "3000:3000"
- "3001:3001"
- "3002:3002"
amc:
image: "aerospike/amc"
links:
- "aerospike:aerospike"
ports:
- "8081:8081"
Then go to http://localhost:8081 and enter in the connect window "aerospike:3000"

How to fix the webdriver config so the test result won't be differ between computers

I write the test on Mac and everything works well.
Then I migrated the test script to server's (ubuntu on Linode) docker container.
The test was failed,
#driver.current_url will show me https://m.flyscoot.com/
but actually I gave the url http://www.flyscoot.com/index.php/en/ to open.
My test was failed by unexpectedly redirected to https://m.flyscoot.com/
I've no idea why this happened?
I guess the web driver was be thought a mobile version browser.
How could I cheat the website so that I can get the identical test result ?
Test failed environment is running on selenium/node-firefox-debug and selenium/hub from this repo https://github.com/SeleniumHQ/docker-selenium
Dockerfile
FROM selenium/node-firefox-debug
....
CMD ["/bin/bash", "/opt/bin/entry_point.sh"]
docker-compose
hub:
image: selenium/hub
ports:
- 4444:4444
web:
build: .
volumes:
- .:/crawler
ports:
- 5900:5900
links:
- hub:hub
entry_point.sh
#!/bin/bash
# RUN THE CRON JOB
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" \
java -jar /opt/selenium/selenium-server-standalone.jar \
-role node \
-hub http://$HUB_1_PORT_4444_TCP_ADDR:$HUB_1_PORT_4444_TCP_PORT/grid/register \
-browser browserName=firefox
--background