cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy scripting - converting string property to integer while sending soap request by setProperty

SOLVED
Highlighted
New Contributor

Groovy scripting - converting string property to integer while sending soap request by setProperty

Hi all,

I've created project level property for a node in soap request which is expecting an integer input, when i try to set that property with the desired value in groovy I'm getting below error. please kindly suggest a solution for this

 

groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [country_name, 123] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) error at line: 19

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

Re: Groovy scripting - set property with an integer

Hi @richie ,

I've found the mistake, i've created a test suite level property but I used setProperty method on project level property in my groovy script, below works fine

code change:

testRunner.testCase.testSuite.setPropertyValue("country_name",cin_value)

 

thanks a lot for ur precious time

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: Groovy scripting - set property with an integer

Hey @Yasar,

Theres a couple of ways of doing this.

Can you provide your groovy please?

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
New Contributor

Re: Groovy scripting - set property with an integer

Hi @richie ,

Thanks for your reply,

PFB groovy script

 

import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.support.GroovyUtils;
import jxl.*
import jxl.write.*

Workbook workbook1 = Workbook.getWorkbook(new File("E:\\Book11.xls"))

Sheet sheet1 = workbook1.getSheet(0) 
size= sheet1.getRows().toInteger() 

WritableWorkbook workbook = Workbook.createWorkbook(new File("E:\\output.xls"))
WritableSheet sheet = workbook.createSheet("Sheet1", 0)

for (def i=0;i<size;i++){
def cin_id = sheet1.getCell(0,i)
def cin_value = cin_id.getContents()

log.info(cin_value)

testRunner.testCase.testSuite.project.setPropertyValue("id",cin_value.toInteger())

def tCase = testRunner.testCase.testSuite.testCases["CapitalTestCase"]
def tStep = tCase.testSteps["Code11"]
tStep.run(testRunner, context)

}

Highlighted
Community Hero

Re: Groovy scripting - set property with an integer

Hey @Yasar,

Have you tried moving the .toInteger() method outside the setProperty method?

E.g.

testRunner.testCase.testSuite.project.setPropertyValue("id",cin_value).toInteger()

If that doesnt work and it should i believe if thats the only issue (although my groovy skills are poor), you could set to int type separately immediately after the setProperty command.

Try above and report back and i'll suggest the other option i know if above doesnt work, although i think this is correct relative to the error response you got.

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
New Contributor

Re: Groovy scripting - set property with an integer

Hi @richie ,

I've tried moving toInteger() outside setProperty method, like below
testRunner.testCase.testSuite.project.setPropertyValue("country_name",cin_value).toInteger()

and getting below error

java.lang.NullPointerException: cannot invoke method toInteger() on null object error at line: 19

Highlighted
New Contributor

Re: Groovy scripting - set property with an integer

Hi @richie ,

I've found the mistake, i've created a test suite level property but I used setProperty method on project level property in my groovy script, below works fine

code change:

testRunner.testCase.testSuite.setPropertyValue("country_name",cin_value)

 

thanks a lot for ur precious time

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors