Fwd: Need Help URG: Issue in reading value from excel sheet

30 views
Skip to first unread message

Chetha Rao A P

unread,
Aug 24, 2016, 11:13:34 PM8/24/16
to testng...@googlegroups.com

Where I should make a modification. ?

Note: All these values are sent to UI as a string when we use webelemen.sendkeys("");


Excel sheet data
Inline image 1


-----------------
 Code To  Read from excel sheet in Data Provider class
____________

//Get Last Row no
int totalNoOfRecords = sheet.getLastRowNum();

Object[][] obj = new Object[totalNoOfRecords][5];
for(int i =1; i<=totalNoOfRecords; i++)
{
XSSFRow row = sheet.getRow(i);
obj[i-1][0] =  row.getCell(0).getNumericCellValue();
obj[i-1][1] =  row.getCell(1).getNumericCellValue();
obj[i-1][2] =  row.getCell(2).getNumericCellValue();
obj[i-1][3] =  row.getCell(3).getStringCellValue();
obj[i-1][4] =  row.getCell(4).getNumericCellValue();
}


-------------------------------------------------------
Code in Test Class
---------------------------------------------------------


//Add Products from Product's fields and submit Enquiry
@Test(dataProvider="validproduct_SEP", dataProviderClass = CreateEnquiryDetailsDataProvider.class, priority=1)
public void submitEnquiryAddProducts(String dly, String cfg, String Configid, String ProdCode, String qty) {



After executing code I received below error
--------------------------------------------------------------------
FAILED: submitEnquiryAddProducts("1.0", "1.0", "1.1111111E7", "232539-888", "2.0")
java.lang.IllegalArgumentException: argument type mismatch
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:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)



--
Thanks and Regards
Chethan Rao



--
Thanks and Regards
Chethan Rao

⇜Krishnan Mahadevan⇝

unread,
Aug 25, 2016, 12:52:44 AM8/25/16
to testng...@googlegroups.com
Your test code is basically reading data from each of the excel column as below :

obj[i - 1][0] = row.getCell(0).getNumericCellValue();
obj[i - 1][1] = row.getCell(1).getNumericCellValue();
obj[i - 1][2] = row.getCell(2).getNumericCellValue();
obj[i - 1][3] = row.getCell(3).getStringCellValue();
obj[i - 1][4] = row.getCell(4).getNumericCellValue();

So for each row, you are basically getting data as below :

double, double, double, String, double

But your method has been defined as below :
public void submitEnquiryAddProducts(String dly, String cfg, String Configid, String ProdCode, String qty)

That explains the mismatch error you are seeing.

To fix this, please change your method definition to something like below :
public void submitEnquiryAddProducts(double dly, double cfg, double Configid, String ProdCode, double qty)


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages