Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple Selenium tests at the same time

Tags:

I would like to run multiple Selenium Tests (on a Jenkins server) at the same time.

It currently runs only a single test at a time cause ChromeDriver seems to communicate over a special port. So somehow I guess I have to pass some kind of port settings via Selenium to the ChromeDriver to start up multiple tests.

The Selenium website unfortunately is empty for that topic: http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#parallelizing-your-test-runs

From my point of view it makes no difference if the Test runs locally or on Jenkins, the problem is the same. We need to somehow configure ChromeDriver. The question is just how.

Anybody has some ideas or pointers where to look at and what files are involved to get this done?

like image 515
seba.wagner Avatar asked Apr 14 '13 23:04

seba.wagner


People also ask

How do I run multiple Selenium tests at once?

We can run multiple test cases using TestNG test suite in Selenium webdriver. To execute test cases simultaneously, we have to enable parallel execution in TestNG. A TestNG execution is driven by the TestNG xml file. To trigger parallel execution we have to use the attributes – parallel and thread-count.

How can we run same test cases on multiple browsers at once in Selenium?

Create an XML which will help us in parameterizing the browser name and don't forget to mention parallel="tests" in order to execute in all the browsers simultaneously. Execute the script by performing right-click on the XML file and select 'Run As' >> 'TestNG' Suite as shown below.

Can you run Selenium tests in parallel?

Selenium parallel execution enables organizations to simultaneously run tests in parallel on different devices and browsers to significantly shrink testing times.


1 Answers

You can run multiple instances of chromedriver locally quite easily, just instantiate multiple driver objects, chromedriver will keep the profiles separate and find a port to run on all by itself.

Here a link to an example that can run multiple tests using TestNG and Maven:

https://github.com/Ardesco/Selenium-Maven-Template

Just clone the above project and run the following in the command line:

mvn verify -Pselenium-tests -Dbrowser=chrome -Dthreads=2 

It takes advantage of TestNG's ability to manage the thread pool and will open up multiple instances if specified. You can do the same thing with jUnit but you'll need to write a custom test runner to fire the tests off into individual threads.

If you decide to use gradle it can deal with managing the thread pools for you with both TestNG and jUnit and a lot of people prefer it to maven.

like image 80
Ardesco Avatar answered Oct 21 '22 16:10

Ardesco