Running multiple Selenium tests at the same time

后端 未结 4 1890
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 06:02

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 commun

相关标签:
4条回答
  • 2020-12-01 06:02

    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.

    0 讨论(0)
  • 2020-12-01 06:06

    I agree using grid in combination with Maven parallelized class, you can run multiple instance in one PC. Jenkins is possible when you are using Ant for your build ,then you can specify which test can be run parallel. Its quite easy to set it up though ;)

    0 讨论(0)
  • 2020-12-01 06:08

    This is an old question, but for anyone still reading along, it is very possible to run multiple Selenium WebDriver instances in parallel without using Grid. I have successfully tested this using Chrome, FireFox, and PhantomJs (up to 5). Each WebDriver instance uses an isolated context, so session conflict should not be an issue. Be wary of server side conflicts though, depending on the requirements of your website!

    For NUnit users, NUnit 3.2.1 now has a 'TestContext.Current.WorkerId' property that will allow you to isolate one WebDriver instance per NUnit worker.

    • Running multiple browsers on the same machine will often hinder performance, so be careful not to use too many browsers instances, or you may actually increase your testing time!
    0 讨论(0)
  • 2020-12-01 06:20

    What you are looking for is Selenium Grid 2.

    Grid allows you to :

    • scale by distributing tests on several machines ( parallel execution )
    • manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS.
    • minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.
    0 讨论(0)
提交回复
热议问题