简体   繁体   中英

Using Docker, with Selenium and Pytest to run parallel tests

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. eg

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

https://github.com/zalando/zalenium

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

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.

您可以根据需要/想要的容器创建尽可能多的容器,然后您将知道容器的 xdist IP,如果您需要 UI 测试,那么 pytest 有 pytest-splinter,如果您需要 bdd 场景,您可以使用 pytest-bdd。

Has this query been answered - if yes could you please update back on the answer too with your findings.

In my point of view pytest-xdist works for parallelisation (irrespective of tests written in webdriver, api's , usual test cases)

Selenium Grid helps us with the distributed effort but limiting to browsers so that one can pass the needed parameters of choice or desired capabilities of target environment to test.

but my view is to combine them to achieve the most efficiency and effectiveness

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM