Forum Discussion

abhishek813's avatar
abhishek813
Frequent Contributor
14 years ago

Not able to set property

I have created a groovy script to run a load test in Soapui. The issue i am facing here is i am not able to set property at any level. i am using soapui 3.5.1 pro.
Please suggest how can i set property using groovy script in load test using script strategy mode? its urgent

5 Replies

  • abhishek813's avatar
    abhishek813
    Frequent Contributor
    Is it an issue with 3.5.1. If i download nightly build, will it solve my problem??
  • Hi,

    can you show the script and tell us in which context it is being executed?

    regards,

    /Ole
    eviware.com
  • abhishek813's avatar
    abhishek813
    Frequent Contributor
    In Soapui, add Load Test to the test suite. For this load test step, select the strategy as "Script"

    The following is one of the step in my script-

    1.Get current time in ms and set it as property value (), i have tried setting the property at global level, test suite level, test case level but it doesnt work from inside load test script window.

    GET works(but only with context.expand) but SET doesnt work.

    def startTime = System.currentTimeMillis();
    def timeIs = startTime.toString()
    def propValue = testRunner.testCase.testSuite.setPropertyValue( "currentTime", timeIs )
    def propVal = testRunner.testCase.testSuite.getPropertyValue("currentTime")
    log.info(propVal)


    Error- No such property-testRunner
    Please suggest if there is some other method to set property in load test.
  • Hi,

    in load test script you can use predefined variables : loadTestRunner, log and context
    so try to use that variable like this

    def startTime = System.currentTimeMillis();
    def timeIs = startTime.toString()
    def propValue = loadTestRunner.loadTest.testCase.testSuite.setPropertyValue( "currentTime", timeIs )
    def propVal = loadTestRunner.loadTest.testCase.testSuite.getPropertyValue("currentTime")
    log.info(propVal)

    Hope this helps

    regards
    nebojsa
    eviware