Hello Friends,
I need help in to get the current row in TestNG data provider.
Scenario:
I have parameterized test case using TestNG data provider. Reading data from excel to feed into the application. This is working fine and test is iterated based on the number of rows in excel. However, I need to store the current row number being executed because I need to pass the row number to another method to set data back to the excel sheet within the same iteration.
For example: Test case is creating a customer and once the customer is created then need to store the generated customer number back to the same row in the excel that is currently in use for execution. Row number is needed in ‘xls.setCellData’ method. Currently I have hard coded as “7”.
Please help.
public class TestWrite extends BaseTest {
String testCaseName = "testWrite";
@Test(dataProvider="getData")
public void testWrite(Hashtable<String,String> data) {
if(createCustomer())
reportPass("Create Customer --> Passed");
else
reportFailure("Create Customer -->Failed");
String customerNumber="00123897"; //this will be generated at runtime
String sheetName = Constant.TESTDATA_SHEET;
xls.setCellData(sheetName, "CustomerNumber", 7, customerNumber);
}
@DataProvider
public Object[][] getData(){
xls = new Xls_Reader(Constant.DATA_XLS_PATH);
return getData(testCaseName, xls);
}
}
Regards
Sohan
What does data parameter of testwrite function look like? Have you test it?
AO,
AO,
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/033c0107-c743-456b-941e-9e8666c09088%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class TestWrite extends BaseTest {
String testCaseName = "testWrite";
@Test(dataProvider="getData")
public void testWrite(Hashtable<String,String> data) {
if(createCustomer(data))
reportPass("Create Customer --> Passed");
else
reportFailure("Create Customer -->Failed");
String customerNumber="00123897"; //this will be generated at runtime
String sheetName = Constant.TESTDATA_SHEET;
xls.setCellData(sheetName, "CustomerNumber", 7, customerNumber);
}
@DataProvider
public Object[][] getData(){
xls = new Xls_Reader(Constant.DATA_XLS_PATH);
return getData(testCaseName, xls);
}
}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b4812a51-e284-4ccf-9b0c-0f0095b8439c%40googlegroups.com.
public class Library { public static void createCustomer(Hashtable<String, String> data) { System.out.println(data.get("row_number")); } }
public class LibraryTest { @DataProvider(name="testData", parallel=false) public Object[][] testData() { return new Object[][] { { new Hashtable<String, String>() {{ put("row_number", String.valueOf(0)); put("name", "ahmet"); put("surname", "ozkesek"); }} }, { new Hashtable<String, String>() {{ put("row_number", String.valueOf(1)); put("name", "hmet"); put("surname", "zkesek"); }} }, { new Hashtable<String, String>() {{ put("row_number", String.valueOf(2)); put("name", "met"); put("surname", "kesek"); }} } }; } @Test(dataProvider="testData") public void createCustomer(Hashtable<String, String> data) { Library.createCustomer(data); }}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/bdc576ec-ca8e-44a0-8a5c-055674b00123%40googlegroups.com.