I am trying to run a parallel test with chrome and Firefox using selenium grid and TestNG.
I am using @DataProvider to make it data driven with single excel file
However, one of the browser get closed every time I try to run my suite and throws the following error stack while one of the browser still functional running the test script successfully:
java.lang.IllegalStateException: Cannot get a STRING value from a NUMERIC cell
at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:1062)
at org.apache.poi.xssf.usermodel.XSSFCell.getRichStringCellValue(XSSFCell.java:395)
at org.apache.poi.xssf.usermodel.XSSFCell.getStringCellValue(XSSFCell.java:347)
at com.opta.ccf.helper.ExcelUtil.getCellData(ExcelUtil.java:90)
at com.opta.ccf.helper.ExcelUtil.getTableArray(ExcelUtil.java:56)
at com.opta.iclarify.test.TDAttTest.osbData(TDAttTest.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:137)
at org.testng.internal.Parameters.handleParameters(Parameters.java:430)
at org.testng.internal.Invoker.handleParameters(Invoker.java:1274)
at org.testng.internal.Invoker.createParameters(Invoker.java:989)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1079)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:400)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
I have the following Items in testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="suite1" verbose="1" parallel="tests">
<test name="firefoxTest">
<parameter name="browser" value="firefox" />
<classes>
<class name="TestAll" />
</classes>
</test>
<test name="chrometest">
<parameter name="browser" value="chrome" />
<classes>
<class name="TestAll" />
</classes>
</test>
</suite>
I have the following for the before test which is inside class called Framework being inherited by child class called TestAll:
@Parameters({"browser"})
@BeforeTest(alwaysRun = true)
public void setup(String browser) throws MalformedURLException {
//Set the desired capabilities
DesiredCapabilities caps = new DesiredCapabilities();
//Setting Desired Capabilities
if(browser.equalsIgnoreCase("Internet Explorer")){
caps = DesiredCapabilities.internetExplorer();
caps.setBrowserName("IE");
}
if(browser.equalsIgnoreCase("firefox")){
caps = DesiredCapabilities.firefox();
caps.setCapability("marionette", true);
caps.setBrowserName("firefox");
}
if(browser.equalsIgnoreCase("chrome")){
caps = DesiredCapabilities.chrome();
caps.setBrowserName("chrome");
}
//Setting Browser
try {
driver = new RemoteWebDriver(new
URL(parentPropFile.getProperty("ServerHubUrl")), caps);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
driver = null;
}
}
My data provider Method is as following which is inside child class TestAll inheriting Framework Class:
@DataProvider(name = "tdData")
public static Object[][] osbData(){
Object[][] testObjArray = null;
try {
testObjArray = ExcelUtil.getTableArray("data-2.xlsx");
} catch (Exception e) {
e.printStackTrace();
}
return testObjArray;
}
And My test method include the following which is inside child class TestAll inheriting Framework Class:
@Test(dataProvider = "tdData", threadPoolSize = 2)
public void testTD(String streetName, String SteetNo,.......){
try {
//TEST SCRIPT
}catch (Exception e) {
e.printStackTrace();
}
}