Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the below code to set the Property Values from Excel file to my Property Step and then pass it to the testcase.

When I run the Groovy code, the value from the last cell of the excel comes to the property step.

Please help me out to set the properties correctly.

What I have tried:

import jxl.*

Workbook wb = Workbook.getWorkbook(new File("C:\\Users\\naraysa1\\Desktop\\Address_Doctor\\DataSource_Address_Validate\\Data_AddressValidate.xls"))
Sheet sh = wb.getSheet(0)
RowCount = sh.getRows();
ColumnCount = sh.getColumns();
for (i=1;i<RowCount;i++)
{
for (j=0;j<ColumnCount;j++)
{
def c = sh.getCell(j, i).getContents();
log.info c

testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("ID", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("AddressLine1", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("AddressLine2", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("AddressLine3", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("City", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("State ", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("PostalCode", c)
testRunner.testCase.getTestStepByName("Properties_Address").setPropertyValue("Country", c)

def TestStep = testRunner.runTestStepByName("Search_Address")
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900