Python + Selenium: Running tests in parallel Python + Selenium: Running tests in parallel selenium selenium

Python + Selenium: Running tests in parallel


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.