1
votes

I am using selenium grid(JUNIT, Java) to run my test case on mutli instance of browser. I used "java -jar selenium-server-standalone-2.20.0.jar -role hub" to run hub. and "java -jar selenium-server-standalone-2.20.0.jar -role webdriver -hub http://machineip:4444/grid/register -port 5566" to run node.

I verified that both are running fine.

But when I run testcase through eclipse only one instace of browser opened.

i used this piece of code.

    @Test
public void method() throws MalformedURLException {
    baseUrl = "https://www.google.co.in";
    nodeUrl = "http://`machinip`:5566/wd/hub";
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    capability.setBrowserName("firefox");
    capability.setPlatform(Platform.WINDOWS);
    driver = new RemoteWebDriver(new URL(nodeUrl), capability);
    // WebDriver driver = new FirefoxDriver();
    driver.get(baseUrl);
    driver.findElement(By.xpath("//td/div/input")).sendKeys("lucky");
}

Can please someone suggest how can i open multiple instance for single test.

Thanks in advance for help.

2
It looks like you are only creating 1 driver there. I don't see where the two drivers come in.Nathan Merrill
Do you mean if i have to run 10 instance i have create 10 drivers?? Can you please provide the code.Lakhwinder Sharma
Why don't you try TestNG for this? its easier to do such works ;)Prashanth Sams
Thx Prashanth. i will use it. but is there any requirment to change in code??Lakhwinder Sharma

2 Answers

0
votes

Try adding this tag when starting the server -browser maxInstances=5

1
votes

you test code looks good in general - for a single test) i think you are missing the way you run the test - if you run it single time it will open a single instance. in testNg you can run it using dataprovider (parameterized) several times, and specify in testing.xml that you want "parallel=methods", this way all your "parametrized" instances of the test will run together. also make sure that u have -browser maxInstances=5, in the node start line (or any number that you want).

efficient selenium testing lab

[disclosure : i work at Ravello]