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.

Easy Setup for Parallel Test Execution with Selenium Docker

90 views

Published on

Parallel execution of test cases is one of the important requirements of a modern test automation framework.
Generally, to run Selenium Suite in parallel, we use selenium grid and distributing tests across multiple machines which will reduce the time required for running tests. To run tests in parallel, we need to configure Selenium Grid with Hub and Nodes where the hub is the central point which will receive test requests along with configurations or capabilities. Based on the request received, the hub will distribute tests to the registered nodes.
Selenium has made a set of Docker images which are available on Docker Hub. We have Selenium Grid, and the browser images - Chrome and Firefox. There are also images with the debug versions which will let as view the test execution.
In this session, we will go through the Selenium tests parallel run setup and configuration.

  • Be the first to comment

  • Be the first to like this

Easy Setup for Parallel Test Execution with Selenium Docker

  1. 1. Easy Setup for Parallel Test Execution with Selenium Docker Sargis Sargsyan 
  2. 2. 2 Sargis Sargsyan Principal Software Engineer in Test
  3. 3. 3 Introduction to Presentation 1 Why? 2 What is Selenium Grid 3 What is Docker Selenium 4 Configure Selenium Grid in Docker Containers 5 Running Selenium Suite in Parallel 6 Creating and maintaining docker-compose file 7 View test execution using debug nodes via VNC 9 Q&A8 Zalenium + Sauce Labs
  4. 4.  Why we should run our test in Parallel? Why?
  5. 5. 5 Why? Why we should run tests in Parallel Running Selenium tests is slow. Parallel testing is allowing us to speed up the test runtime. Also it allows us to increase coverage and run tests in different browser on the same time. Parallel Test Running Possibility to test more than one set of configurations Save Time! Reduce the time of test suite run Cost per Test to run More browser/OS coverage Fast feedback Less Manual Testing
  6. 6. 6 Disadvantages  What are the disadvantages of Selenium Grid The performance of Selenium grid is low, in case if you are running large amount of the test and need large amount of nodes Setting up parallel running test suite requires time In case of large amount of tests it will be necessary to divide the suite into parts and run them in different machines If the suite was divided to pars there will be some difficulties in analyzing statistics, as there will be divided reports As the code is executed on the same machine the test were launched and the machine only receives the browser control commands. It is creating issues with uploading or downloading files
  7. 7.  What is Selenium Grid
  8. 8. 8 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
  9. 9. 9 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
  10. 10. 10 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
  11. 11.  A flexible and scalable Selenium Grid Zalenium
  12. 12. 12 Zalenium A grid that scales using docker-selenium Ƽ Hard to maintain a Selenium Grid Ƽ Allow anyone to have a disposable and flexible Selenium Grid infrastructure Why Zalenium?What is Zalenium? Dinamic, on-demand Selenium Grid Based on docker-selenium Simple to setup and run a * Zalenium
  13. 13. 13 Zalenium Additional Features  Get a grid up and running in a few seconds! Test status and steps directly in the video Basic auth grid protection when deploying Zalenium in the cloud (AWS, GCP, …) Mount volumes across containers when you need to specific files in your tests a * Zalenium
  14. 14. 14 How It Works?  Zalenium works conceptually in a simple way a * Zalenium
  15. 15. 15 How It Works?  Zalenium works conceptually in a simple way a * Zalenium
  16. 16. 16 How to Build Zealenium?  Zalenium works conceptually in a simple way a * Zalenium docker pull elgalu/selenium docker pull dosel/zalenium
  17. 17. 17 How to Build Zealenium?  Zalenium works conceptually in a simple way a * Zalenium docker run --rm -ti --name zalenium -p 4444:4444 -e DOCKER=17.06.2-ce -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos --privileged dosel/zalenium start
  18. 18.  Zalenium works conceptually in a simple way How to Build Zalenium?
  19. 19. 20 How to Build Zealenium with docker-compose?  Zalenium works conceptually in a simple way a * Zalenium # Usage: # docker-compose up --force-recreate version: '2.1' services: zalenium: image: "dosel/zalenium" container_name: zalenium hostname: zalenium tty: true volumes: - /tmp/videos:/home/seluser/videos - /var/run/docker.sock:/var/run/docker.sock - /usr/bin/docker:/usr/bin/docker ports: - 4444:4444 command: > …………………………. ………………………….
  20. 20.  Zalenium works conceptually in a simple way How to Run Test?
  21. 21. 23 How to Build Zalenium?  Zalenium works conceptually in a simple way
  22. 22.  Zalenium works conceptually in a simple way View browser via VNC in Zalenium?
  23. 23.  Cloud-hosted web and mobile application automation platform Sauce Labs
  24. 24. 28 Sauce Labs  A flexible and scalable Selenium Grid As the co-developers of Selenium, our team maintains the most up-to-date and reliable platform for web testing. Test securely knowing that our experts can help your organization build their test automation strategy. What is Sauce Labs Ƽ Run Selenium tests in real browsers in cloud Write test in most popular languages Specify platform configuration Spent less time to setting up and maintaining your testing infrastructure a * Sauce Labs
  25. 25. 29 Sauce Labs  A flexible and scalable Selenium Grid a * Sauce Labs
  26. 26. 30 How to Run Tests Against Sauce Labs?  Cloud-hosted web and mobile application automation platform
  27. 27.  Cloud-hosted web and mobile application automation platform How to Run Tests Against Sauce Labs?
  28. 28.  Redirect the test to a cloud testing provider Zalenium + Sauce Labs
  29. 29. 34 Zalenium + Sauce Labs  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam. If you need a capability that cannot be fulfilled by docker-selenium, the test gets redirected to a cloud testing provider (i.e. Sauce Labs) Zalenium + Sauce Labs
  30. 30. 35 How to Build Zealenium with Saucelabs?  Zalenium works conceptually in a simple way a * Zalenium export SAUCE_USERNAME=<your Sauce Labs username> export SAUCE_ACCESS_KEY=<your Sauce Labs access key> export SAUCE_LABS_URL=<your Sauce Labs url:port number>
  31. 31. 36 How to Build Zealenium with Saucelabs?  Zalenium works conceptually in a simple way a * Zalenium docker run --rm -ti --name zalenium -p 4444:4444 -e SAUCE_USERNAME -e SAUCE_ACCESS_KEY -e SAUCE_LABS_URL -v /tmp/videos:/home/seluser/videos -v /var/run/docker.sock:/var/run/docker.sock --privileged dosel/zalenium start --sauceLabsEnabled true
  32. 32. 37 How to Build Zealenium with Saucelabs?  Zalenium works conceptually in a simple way
  33. 33. 38 Create Remote Driver for Chrome  Zalenium works conceptually in a simple way
  34. 34.  Zalenium works conceptually in a simple way Run Selenium Tests on Chrome
  35. 35. 41 Create Remote Driver for Chrome / Windows Zalenium works conceptually in a simple way
  36. 36.  Zalenium works conceptually in a simple way Run Selenium Tests on Chrome / Windows
  37. 37. 44 Tools and Services  Selenium Web Driver Zalenium/Selenium Grid Sauce Labs Docker https://github.com/sargissargsyan/selenium-parallel-run
  38. 38. 45 Thank You! Ñ sargis.sargsyan@live.com t @sargisset ą /in/sargissargsyan

×