Tech Me More

To quench our thirst of sharing knowledge about our day to day experience & solution to techincal problems we face in our projects.

Advertise with us !
Send us an email at diehardtechy@gmail.com

Wednesday, May 8, 2019

RUNNING SELENIUM TEST IN DOCKER CONTAINER USING JENKINS WITH ZALENIUM & GRADLE.


RUNNING SELENIUM TEST IN DOCKER CONTAINER USING JENKINS WITH ZALENIUM & GRADLE.

Step 1:
Pull Jenkins image and run it.
Use the below command to pull and run the Jenkins docker instance.
docker run -p 8085:8080 jenkins/jenkins:lts
once the above command is executed, you will see the below output.





As you can see from the above output “Jenkins is up and running.”
Navigate to http://localhost:8085 to access the Jenkins.
Install Git & Gradle plugin.
Step 2:
Pull Zalenium docker image and run it.
 # Pull docker-selenium
docker pull elgalu/selenium

# Pull Zalenium
 docker pull dosel/zalenium

 # Run it!
  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


After the above command is executed, you can see the output as below.



From the above-highlighted content, you can see, selenium grid is up and running. Please use http://localhost:4444/wd/hub to connect to selenium hub.

Visit: http://localhost:4444/dashboard/# this will open Zalenium dashboard. Zalenium dashboard is a unique dashboard for all test execution status and report.




Visit: http://localhost:4444/grid/admin/live to see the live execution happening in docker container created by Zalenium.



Step 3:
Point your Selenium test to http://localhost:4444/wd/hub and run it.
If you wish to run this in Jenkins please use ip address of your host machine.
I have created a sample Java-Gradle project and kept it in bitbucket.
Step 4:
Create a Jenkins job, which have bitbucket configuration for above repo. And try running it. Sample configuration from Jenkins looks like below:






Happy learning. 


No comments: