4

I'm trying to use these all things together to run parallel tests in a headless chrome:

Docker, Selenium, Pytest

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

Docker can do this (using selenium grid). Both these can be used to run parallel (and distributed) selenium tests. e.g.

https://github.com/elgalu/docker-selenium

https://github.com/zalando/zalenium

Also Pytest has its own way of running parallel tests (using pytest-xdist) e.g.

http://pytest.org/dev/xdist.html

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

I would be grateful to find out the advantages/disadvantages are for each.

Also, any idea how to use these things together? Information on this seems really sparse.

Ke.
  • 2,484
  • 8
  • 40
  • 78

2 Answers2

0

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.

0

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.

lucrib
  • 448
  • 1
  • 9
  • 21