how to get/set TestStep's property value using javascript in soapUI?

i have tried using Groovy script. the following code is to set property value using roovy script:

testRunner.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].setPropertyValue("request",object); 

"request" is a property of testStep. object is a some value.

when i try above code in javascript but i got following error:

org.mozilla.javascript.ecmaerror: TypeErro: org.mozilla.javascript.ecmaerror Cannot read property "testSteps" from undefined.

So please tell me how to use in using javascript?

javascriptautomated-testssoapui

Answers

answered 3 months ago bhavesh.sarvaiya #1

hurra, i got solution. Please see following code:

var project = testRunner.getTestCase().getTestSuite().getProject();
var testSuite = project.getTestSuiteByName("TestSuite");
var testCasesItr=testSuite.getTestCaseList().iterator();
while(testCasesItr.hasNext())
{
        var testStepsItr = testCasesItr.getTestStepList().iterator();
        while(testStepsItr.hasNext()){
            var testStep = testStepsItr.next();
            log.info(testStep.getPropertyValue("response"));
              // here you can set property
              // testStep.setPropertyValue("request","someValue");

        }

}

above code will run for all the testcases.

comments powered by Disqus