4

How do I run multiple tests in parallel? The tests are written in Python, suite kicks off from jenkins and runs on sauce labs.

When I set up different jobs in jenkins and run them simultaneously they will all fail, I think it is because they aren't set up to run that way.

I apologize if this is a very convoluted question, I was hoping someone could point me in the right direction and I am willing to provide additional documentation.

I've checked this link http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html

and I do run the tests using nose but am not sure if I set it up correctly.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Kevnyou
  • 83
  • 1
  • 8
  • Possible duplicate of [Python parallel execution with selenium](https://stackoverflow.com/questions/42732958/python-parallel-execution-with-selenium) – Mate Mrše Apr 25 '19 at 10:23

1 Answers1

0

I've also had trouble running Selenium tests in parallel under nose with both Windows and CentOS 7, and with both CPython 3.5.1 AND CPython 3.4.6.

I recommend you switch to pytest and run in parallel using pytest-xdist. A github repository demonstrating how to combine pytest, 'pytest-xdist, andselenium` is available at https://github.com/danizen/python-selenium-parallel.

The key considerations are making sure that an instance of Selenium Webdriver is specific to a process. My recommendation is to use threading.local for that, but my example does it instead by sharing only at the class level.

I also think there's a general need to provide a way for DevOps and developers to specify the parameters for creating the Selenium web driver based on environment variables or command-line options. See https://pypi.org/project/holmium.core/ for one take on how to do that - they may also support multi-threading, but I am not sure. I don't endorse holmium's idea of page objects, however, and many selenium grids are home grown. See https://github.com/ncbi/robotframework-pageobjects/ for another way to do this, this time with robotframework.

Note that nose development has been stopped, but I imagine it would work, at least on Linux, if you are using CPython 2.7.

danizen
  • 431
  • 5
  • 4