Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Easy Setup for Parallel Test Execution with Sel...

Easy Setup for Parallel Test Execution with Selenium Docker

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.

Sargis Sargsyan

November 23, 2018
Tweet

More Decks by Sargis Sargsyan

Other Decks in Programming

Transcript

  1. 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&A 8 Zalenium + Sauce Labs
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 16 How to Build Zealenium?  Zalenium works conceptually in

    a simple way a * Zalenium docker pull elgalu/selenium docker pull dosel/zalenium
  10. 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
  11. 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: > …………………………. ………………………….
  12. 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
  13. 30 How to Run Tests Against Sauce Labs?  Cloud-hosted

    web and mobile application automation platform
  14. 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
  15. 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>
  16. 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
  17. 44 Tools and Services  Selenium Web Driver Zalenium/Selenium Grid

    Sauce Labs Docker https://github.com/sargissargsyan/selenium-parallel-run