Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to Dockerize Parallel Execution of Selenium Tests

178 views

Published on

Reducing end to end test execution time is key for software development life cycle that wish to implement continuous integration and delivery. Selenium WebDriver allows us to run e2e tests on web applications in different browsers. As it runs across many browsers and operating systems there are lots of possible capabilities to test. This workshop will help you to get started with the setup of dockerizing parallel execution of Selenium tests by cutting your test runtime up to 10 times. We’ll also look at how to run tests against a number of browsers and capabilities.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

How to Dockerize Parallel Execution of Selenium Tests

  1. 1. How to Dockerize Parallel Execution of Selenium Tests Sargis Sargsyan  Workshop, SQA Days EU, Latvia 2019
  2. 2. 2 Sargis Sargsyan Director, Quality Assurance at PicsArt
  3. 3. 3 Introduction to Presentation 1 Why? 2 What is Selenium Grid 3 Running Selenium Suite in Parallel 4 What is Docker Selenium 5 Configure Selenium Grid in Docker Containers 6 Creating and maintaining   docker-compose file 7 Zalenium  9 Q&A8 Selenoid
  4. 4.  Getting Started with Selenium Grid & Docker
  5. 5. 5 What is Selenium Grid Selenium Grid is a smart proxy server that allows Selenium tests to route commands to remote web browser instances. Its aim is to provide an easy way to run tests in parallel on multiple machines. With Selenium Grid, one server acts as the hub that routes JSON formatted test commands to one or more registered Grid nodes. Tests contact the hub to obtain access to remote browser instances. The hub has a list of registered servers that it provides access to, and allows us to control these instances. Selenium Grid allows us to run tests in parallel on multiple machines, and to manage different browser versions and browser configurations centrally (instead of in each individual test). Selenium Grid isn't a silver bullet. It solves a subset of common delegation and distribution problems, but will for example not manage your infrastructure and might not suit your specific needs. Selenium Grid a *SeleniumHQ Documentation Diagram from https://www.ranorex.com
  6. 6. 6 What is Selenium Hub and Nodes • Intermediary and manager • Accepts requests to run tests • Takes instructions from client and executes them remotely on the nodes • Manages threads Hub a *SeleniumHQ Documentation • This is where the browsers live • Registers itself to the hub and communicates its capabilities • Receives requests from the hub and executes them Nodes
  7. 7. 7 Docker Selenium Grid • Selenium hub image • Selenium node-firefox image • Selenium node-chrome image • Selenium node-firefox-debug image • Selenium node-chrome-debug image Selenium Images a *SeleniumHQ Documentation As normal grid with docker we have to install the hub and browser nodes into Docker containers and then start the hub and nodes from the Docker container. Selenium Grid with Docker
  8. 8. Prepare Sample Tests Run tests: Open a terminal Clone this project 
 ~$ git clone https://github.com/sargissargsyan/selenium- parallel-run.git cd selenium-parallel-run mvn clean install -DskipTests mvn failsafe:integration-test
  9. 9.  Setup Selenium Docker locally Selenium Docker
  10. 10. How to Dockerize Parallel Execution of Selenium Tests Run tests: Open a terminal Clone this project 
 ~$ git clone https://github.com/sargissargsyan/selenium- parallel-run.git cd selenium-parallel-run mvn clean install -DskipTests mvn failsafe:integration-test -Dselenium.remote=false
  11. 11. How to Dockerize Parallel Execution of Selenium Tests Demo
  12. 12. 12 How to Dockerize Parallel Execution of Selenium Tests ~$ docker -v Docker version 18.09.2, build 6247962
  13. 13. 13 How to Dockerize Parallel Execution of Selenium Tests java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) ~$ java -version
  14. 14. 14 How to Dockerize Parallel Execution of Selenium Tests Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T22:41:47+04:00) ~$ mvn -v
  15. 15. 15 How to Dockerize Parallel Execution of Selenium Tests docker-compose version 1.23.2, build 1110ad01 ~$ docker-compose -v
  16. 16. 16 How to Dockerize Parallel Execution of Selenium Tests docker-machine version 0.16.1, build cce350d7 ~$ docker-machine -v
  17. 17. How to Dockerize Parallel Execution of Selenium Tests ~$ docker network create grid
  18. 18. 18 How to Dockerize Parallel Execution of Selenium Tests ~$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/ standalone-chrome:3.141.59-lithium
  19. 19. 19 How to Dockerize Parallel Execution of Selenium Tests ~$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/ shm:/dev/shm selenium/node-chrome:3.141.59-lithium
  20. 20. How to Dockerize Parallel Execution of Selenium Tests
  21. 21. How to Dockerize Parallel Execution of Selenium Tests Demo
  22. 22. How to Dockerize Parallel Execution of Selenium Tests ~$ docker network rm grid ~$ docker stop selenium-hub ~$ docker rm selenium-hub ~$ docker stop chrome-node ~$ docker rm chrome-node
  23. 23. Selenium Docker up using Docker Compose ~$ cd /selenium-parallel-run ~$ docker-compose -f docker-compose-selenium-docker.yml up -d ~$ docker-compose -f docker-compose-selenium-docker down
  24. 24. Selenium Docker up using Docker Compose Demo
  25. 25.  A flexible and scalable Selenium Grid Zalenium
  26. 26. 26 How to Build Zealenium?  Zalenium works conceptually in a simple way a * Zalenium ~$ docker pull elgalu/selenium ~$ docker pull dosel/zalenium
  27. 27. 27 How to Build Zealenium?  Zalenium works conceptually in a simple way a * Zalenium ~$ 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
  28. 28. How to Dockerize Parallel Execution of Selenium Tests Demo
  29. 29. Zalenium up using Docker Compose ~$ cd /selenium-parallel-run ~$ docker-compose -f docker-compose-zalenium.yml up --force-recreate -d ~$ docker-compose -f docker-compose-zalenium.yml down
  30. 30. Zalenium up using Docker Compose Demo
  31. 31.  Selenoid
  32. 32. 32 Pre steps Create a directory with name selenoid ~$ mkdir selenoid Create browsers.config file ~$ mkdir config ~$ touch config/browsers.json Change directory to selenoid ~$ cd selenoid/ Edit browsers.config file ~$ nano browsers.config
  33. 33. browser.json { "chrome": { "default": "72.0", "versions": { "72.0": { "image": "selenoid/vnc:chrome_72.0", "port": "4444", "path": "/" } } } }
  34. 34. 34 How to Build Selenoid? ~/selenoid$ docker run -d --name selenoid -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock -v `pwd`/config/:/etc/selenoid/:ro aerokube/selenoid:latest-release
  35. 35. Selenoid Demo
  36. 36. 36 How to Build selenoid-ui? ~/$ docker run -d --name selenoid-ui --link selenoid -p 8080:8080 aerokube/selenoid-ui --selenoid-uri=http://selenoid:4444
  37. 37. Selenoid Demo
  38. 38. 38 How to Build Selenoid with Configuration Manager? ~/$ curl -s https://aerokube.com/cm/bash | bash ~/$ ./cm selenoid start --vnc > ./cm.exe selenoid start --vnc https://github.com/aerokube/cm/releases ~/$ ./cm selenoid-ui start
  39. 39. Selenoid Demo
  40. 40. 40 Links https://github.com/SeleniumHQ/docker-selenium https://opensource.zalando.com/zalenium/ https://aerokube.com/selenoid/latest/ https://aerokube.com/cm/latest/
  41. 41. 41 Thank You! Ñ sargis.sargsyan@live.com t @sargiset ą /in/sargissargsyan

×