Forum Discussion

dlizarazo's avatar
dlizarazo
Occasional Contributor
12 years ago

Passing Values from groovy script to properties and Vic Vera

I am getting error message

groovy.lang.MissingPropertyException: No such property: No Such property: ManyValuesFor1Input for class: Script15 error at line 4

Here is my script

def itemList =[2020,1009,2035]
def counter =0

counter = ManyValuesFor1Input.ManyToOne.PropertyValues.PropertyValues["Counter"].value

ManyValuesFor1Input.ManyToOne.PropertyValues["ItemId"].value = itemList[counter]
ManyValuesFor1Input.ManyToOne.PropertyValues["Counter"].value = counter++

3 Replies

  • dlizarazo's avatar
    dlizarazo
    Occasional Contributor
    Now I have changed it to

    def itemList =[2020,1009,2035];
    def counter =0;

    def myItem = new java.util.Properties();
    myItem = testRunner.testCase.getTestStepByName("PropertyValues");

    myItem.setPropertyValue("ItemId",itemList[counter]);
    myItem.setPropertyValue("Counter",counter++);

    now I get error

    groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [ItemId, 2020] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) error at line: 7
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi dlizarazo,

    It would appear that you're not iterating over this correctly. I have made some minor alterations as follow, but you'll see, by running the step, that you're not iterating, and not getting a value for the counter:

    def itemList =[2020,1009,2035];
    def counter = 0;

    def myItem = new java.util.Properties();
    myItem = testRunner.testCase.getTestStepByName("PropertyValues");

    def thisItem = itemList[counter];
    def thisCount = counter++;

    //myItem.setPropertyValue("ItemId",thisItem);
    //myItem.setPropertyValue("Counter",thisCount);

    log.info("ItemId property set to: " + thisItem);
    log.info("Counter property set to: " + thisCount);


    Some things to bear in mind:

    1. I believe any property is treated as a string field, so if you're going to increment Counter by 1, you may have to convert/cast as an integer.
    2. You will probably need to have a setup script to handle the creation of your array data and initial values. Likewise, you'll need the same on a teardown, otherwise you'll have to manually reset the property values when re-running the test.
    3. Rather than iterate based upon a counter, why don't you count the values in the array, and use a iterate on a for loop, or similar? I've provided an implementation of this at viewtopic.php?f=5&t=15500&sid=51f34fddfdaf8e72f4801b3ba013947c#p37045

    Kind regards,
    Tim
  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    try it yourself: (below is a sample on how to set property value into properties of test case)

    def tc = context.testCase
    def itemList = ['2020','1009','2035']
    def counter = 0
    itemList.each{
    tc.setPropertyValue("ItemId${counter}",it)
    counter++
    }