I 'm using testNg + selenium grid for my test session and i'm very happy with the whole stuff The point is that the number of tests is growing and now they need at least 3 hrs to be executed ( +-100 tests on thre browsers) I plan to have +-150 tests so, as You can imagine , I must find a solution and start them in parallel I tried to play a bit with this but no luck for now, what I see right now is that two browsers start but only one go through the test .The other one just wait :-) The structure of the test is like the one below, basically 1 test=1 class. I have a @BeforeClass ( start driver) and a @AfterClass (stop the driver) before/after every test
testNG.xml -> i changed parallel= to classes,methods,tests but no luck.Also changed thread-count value !
<test name="Smoke Test in IE - IE REMOTE" preserve-order="true">
<parameter name="browser" value="IE" ></parameter>
<classes>
<class name="com.TestThis.Script1" />
<class name="com.TestThis.Script2" />
</classes>
</test>
TEST CLASS LOOKS LIKE THIS public class Script1 extends SelTestCase {
try {
GlobalHelp.LogIn("usr","pwd");
customVerification.verifyTrue("Verify main page loaded( check download zone is visible!!)", ObjectHelp.isElementVisible(ObjectsPaths.Main_DownloadZone,120000)==true);
customVerification.SoftVerifyEquals("Verify main page is displayed " , driver.getTitle(), "Application Stuff");
} catch (Exception e) {
Reporter.log("from exception" + e.toString());
customVerification.verificationErrors.append(e);
}
}
}
MODULE WITH BEFORE & AFTER LOOK LIKE THIS public class SelTestCase {
@BeforeSuite
@Parameters("appURL")
public void setEnv(
@Optional(ObjectsPaths.MAIN_URL) String appURL) {
this.appURL = appURL;
}
@BeforeClass
@Parameters({ "browser", "HUBip" })
public void launchBrowser(@Optional("IE") String browser, @Optional("localhost") String HUBip) throws MalformedURLException {
String brw=browser;
String ip=HUBip;
try {
if (sBrw.equalsIgnoreCase("Chrome")) {
URL url = new URL( "http","localhost",4444, "/wd/hub" );
DesiredCapabilities caps=DesiredCapabilities.chrome();
driver = new ScreenShotRemoteWebDriver(url, caps);
} else if (sBrw.equalsIgnoreCase("FF")) {
URL url = new URL( "http", "localhost",4444, "/wd/hub")
DesiredCapabilities caps=DesiredCapabilities.firefox();
} else {
URL url = new URL( "http", "localhost",4444, "/wd/hub" );
DesiredCapabilities caps=DesiredCapabilities.internetExplorer();
driver = new ScreenShotRemoteWebDriver(url, caps);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
}
try {
Reporter.log("Test started at: " + ObjectHelp.getDate() + "<p>");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait( ObjectHelp.PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS );
driver.manage().timeouts().pageLoadTimeout(ObjectHelp.PAGE_LOAD_TIMEOUT,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.navigate().to("http://www.google.com");
}
//TBD
@AfterClass
public void closeBrowser() throws Exception {
//driver.close();
QuitDriver();
}