varworld
varworld

Reputation: 1

Running tests on multiple browsers with selenium grid and junit

I am trying to set up automated selenium testing but don't know how to run tests in multiple browsers. Based on reading stuff online I have selenium grid up and running with multiple browsers and it successfully executes my tests.

I am trying to figure out how to setup my junit tests so that it runs all the browsers one after another or in parallel is possible. Here is my code:

selenium = new DefaultSelenium("grid.host.here", "4444", "*firefox", "http://host.com");

With this code it only runs firefox, how do I tell it to run firefox, iexplore and safari without creating new instantes of the object? I have seen examples in PHP and Python where you can pass an array of browsers and it runs them one after another. Couldn't find anything for Java.

Upvotes: 0

Views: 2864

Answers (1)

nirvdrum
nirvdrum

Reputation: 2319

You need to create multiple DefaultSelenium objects. It's what maintains the browser session (i.e., the connection to the grid RC). Selenium Grid ships with examples of doing this with TestNG. If you need to use jUnit, I've seen people succeed with parallel-junit.

At the core of it, there's no magic going on. You have N RC workers, so your tests need to establish N connections to fully utilize your workers. If you try to connect N + 1, the client will simply block until an RC becomes available. Just be sure to tune your grid setup to handle that. It's possible the client times out before the RC becomes available, which can create a tricky situation.

Upvotes: 3

Related Questions