Forum Discussion

ABCDEFG's avatar
13 years ago

Groovy: setPropertyValue()


Can some one help me to use setPropertyValue() function?

I need to update a value in the property test step. Dynamically I am getting value in 'abc' parameter and 'line1' value need to update in 'abc' parameter in Properties test step.


This giving error message. Pls help!

Can you please...


4 Replies

  • 1. What is the error message?
    2. doesn't setPropertyValue(java.lang.String name, java.lang.String value) take two arguments not the 3 you have given "setPropertyValue(%s,"abc",line1)"?
  • deepesh_jain's avatar
    Frequent Contributor
    First Get rid of %s in your statement.
    Next try using this:


    It should work.
  • I agree its 3 Parameters fn(). Could you help me with right values, if this fn() is not working.

    following is the Error msg,

    <org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script99.groovy: 19: expecting EOF, found '(' @ line 19, column 70. Properties1").setPropertyValue(%s,"abc", ^ org.codehaus.groovy.syntax.SyntaxException: expecting EOF, found '(' @ line 19, column 70. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST( at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST( at org.codehaus.groovy.control.SourceUnit.parse( at org.codehaus.groovy.control.CompilationUnit$ at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits( at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation( at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations( at org.codehaus.groovy.control.CompilationUnit.compile( at groovy.lang.GroovyClassLoader.doParseClass( at groovy.lang.GroovyClassLoader.parseClass( at groovy.lang.GroovyShell.parseClass( at groovy.lang.GroovyShell.parse( at groovy.lang.GroovyShell.parse( at groovy.lang.GroovyShell.parse( at at at at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$ at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$ Source) at Source) Caused by: Script99.groovy:19:70: expecting EOF, found '(' at groovyjarjarantlr.Parser.match( at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit( at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST( ... 20 more 1 error >

  • Deepesh,

    I will elaborate it more. Pls go thrgh the below content,

    This is my program-

    /*To Access Properties of a Test case and update it from i/o file*/
    def proj = testRunner.testCase.testSuite.project;
    def tsuite = testRunner.testCase.testSuite;
    def tcase = testRunner.testCase;

    //Reading from File
    myFile = new File("C:\\Documents and Settings\\ABCDEFG\\Desktop\\soapUI\\params.txt")
    for (def j=0; j<myFile.readLines().size(); j++)
    line1= myFile.readLines().get(0)
    line2= myFile.readLines().get(1)
    for (def i=0; i<2; i++)
    def Pnme = tcase.getTestStepByName("Properties1").getPropertyAt(i).getName();
    def Pvalue= tcase.getTestStepByName("Properties1").getPropertyAt(i).getValue();
    //Update properties

    What i need to do is, Need to Dynamically use Value1/Value2 [in Bold letters] and change it value in Pname field and update the parameter's?