简体   繁体   中英

How can I run a TestNG/Selenium test suite in IE on multiple servers in parallel?

I have a Selenium test suite using the IEDriver that I run with TestNG . The goal is to use this test suite for regression. I want to run this test suite against each of the production servers. Currently I can point it at any of the servers and run the tests. However, the problem is that I can only run one at a time. Running them serially takes too long. Having one windows server pointed at each Linux production server is not a feasible or scalable option. I want some way to run them on separate threads, from one windows server if possible.

I have been looking into the Selenium Grid/Remote Driver , but I'm not sure if this is the right solution or how to implement it for my goals. From what I've read about it, I think I would want each "node" to be a different production server, but I am completely new to this technology.

I've looked around stack overflow, but I haven't found anything that quite answers my question. If anybody has experience with this sort of problem or with these technologies I would appreciate your input.

I did implement such thing using Selenium Grid.

What you need to do is:

  1. Download Selenium Server here
  2. Start a Selenium hub on one server like this:

    java -jar selenium-server-standalone-2.44.0.jar -role hub

  3. Start Selenium nodes on each one of the test servers like this:

    java -jar selenium-server-standalone-2.44.0.jar -role node -hub http://localhost:4444/grid/register

  4. Create your driver using the Selenium hub like this:

    CommandExecutor executor = new SeleneseCommandExecutor(new URL("http://localhost:4444/"), new URL("http://www.google.com/"), capabilities);

    WebDriver driver = new RemoteWebDriver(executor, capabilities);

More info here and here

In Selenium Grid, you have:

L : a machine executing your Java code (your local machine or a Jenkins node).

N : one or more machines hosting the browser instances your tests run on.

H : a machine responsible for directing traffic between L and N .

When you have too many tests to run the whole suite on one machine, this is a very helpful choice. If you have your own grid of VMs, I suggest using SeleniumGridExtras --it handles some of the weirdness of IE Webdriver. If you don't, you can get set up quickly using BrowserStack or SauceLabs .

Even without Selenium Grid, you can run multiple test threads locally using parallel execution and increasing your thread count. (Either threadPoolSize = 3 on a specific @Test annotation, or parallel="methods" thread-count="28" in your suite xml file.)

No matter what, though, the per-machine execution time of Selenium tests is high enough that it makes sense to run your suites in series. In IE it's often considered unwise to run more than one test at a time on a given machine. You can chain Jenkins jobs to have them complete one after the next after the next.

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