Using Docker, with Selenium and Pytest to run parallel tests Using Docker, with Selenium and Pytest to run parallel tests selenium selenium

Using Docker, with Selenium and Pytest to run parallel tests


You create as much as you need/want containers then you will let know xdist IPs of containers and if you need UI tests then pytest has pytest-splinter and if you need bdd scenarios you can use pytest-bdd.


However, I'm wondering where it makes sense to run the parallel part of the system?

Each part will contribute for the parallelism to happen.You need Selenium HUB to orchestrate available browsers to run a test. You can have n browser running in headless mode, each one isolated in its own container.

Would it be easier to run 10 parallel pytest-xdist than running 10 docker containers?

Pytest will parallelize the test execution for you, bur not the instantiation and orchestration to the available browsers.

Summarizing:

Problem: You need to run UI (Selenium) tests in parallel. You will need N amount of browsers available to run this test.

Solution: You can start N nodes of headless chrome from docker.problem: You have 10 different connection options to give to your drivers in your tests.

Solution: Start selenium hub and let it manage these for you. So you have to concern with only one connection point and then it will give you the browser that is free to run that test.

Problem: You run you tests now and only one browser is being used.Solution: Use xdist to instruct pytest to run X amount of tests per time. X in this case can match with N number of browser available.