1
votes

This is my TESTNG.xml

`<suite name="Test Suite">
<test name="test" parallel="classes" thread-count="2" preserve-order="true">
<classes>
<class name="Test1"/>
<class name="Test2"/>
<class name="Test3"/>
<class name="Test4"/>
<class name="Test5"/>
</classes>
</test>
</suite>`

Hub: java -jar selenium-server-standalone-2.43.1.jar -role hub -maxSession=2

Node: java -jar selenium-server-standalone-2.43.1.jar -Dwebdriver.chrome.driver=%chromeDriverPath% -role webdriver -hub http://%hubIPAndPort%/grid/register -maxSession 2 -browser "platform=%platform%,javascriptEnabled=true,browserName=%browserName%,takesScreenshot=true,version=%browserVersion%,maxInstances=%maxInstances%"

Problem:

When I run Two test classes with 2 maxSession count it works fine (Same with 5, 10, 15 ..)

But when I add a test more than the maxSession specified, say I added three more tests,now test spawns with two browsers, gets the LandingPage but would't proceed.

TestNG version: 6.8.8 Selenium version: 2.43.1

What am I doing wrong here ?

1
Please share the code where you are creating the driver. - Shamik

1 Answers

0
votes

Obviously I wasn't using ThreadLocal and my driver instance was also static. Started using ThreadLocal and got by problem fixed.

public void instantiateDriverObject(String browser) {
DriverFactory factory = new DriverFactory();
driver = factory.createInstance(browser);
driverThread = new ThreadLocal<WebDriver>() {
@Override
protected WebDriver initialValue() {
webDriverPool.add(driver);
return driver;
}
};
}