Error reading excel file and save it in SoapUI's Test suite properties

406 Views Asked by At

Trying to read data from excel file and save it in Test suite properties, but getting this error (Using SOAP UI 5.1.3)

//This is the code

import java.io.*
import jxl.*
def file =new File("D:\\GroovyTest\\Example.xls")
def wb=Workbook.getWorkbook(file)
def sheet=wb.getSheet("Sheet1")
r=sheet.getRows()
for(int i=1;i<2;i++)
{
    Cell c1=sheet.getCell(0,i)
    testRunner.testCase.testSuite.addProperty("CityName"+i)
    String cityName =c1.getContents()
    testRunner.testCase.testSuite.setProperty("CityName"+i,cityName)
    testRunner.runTestStepByName("GetSupplierByCity")   
}

this is Error:

Error: groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestSuite.setProperty() is applicable for argument types: (java.lang.String, java.lang.String) values: [CityName1, New York] Possible solutions: getProperty(java.lang.String), addProperty(java.lang.String), hasProperty(java.lang.String), hasProperty(java.lang.String), getProject(), getProperties() error at line: 12

1

There are 1 best solutions below

2
On

You are very close to get it.

As the error says, there is no such method setProperty.

In order to set either new property or modify existing property, use just setPropertyValue method.

So, all you need to do is simple. Remove below statement from your code.

testRunner.testCase.testSuite.addProperty("CityName"+i)

And change below statement

From:

testRunner.testCase.testSuite.setProperty("CityName"+i,cityName)

To:

testRunner.testCase.testSuite.setPropertyValue("CityName"+i,cityName)