Forum Discussion

shiva_kakarla's avatar
shiva_kakarla
Contributor
15 years ago

Command line testRunner.testCase.getTestStepByName( "Request 1" ); does not work

Hi I am running below statement in my groovy script and "request" variable is always null. It works when I execute in UI but not in commandline. I am using 2.5.1 version.
Both the groovy step and HTTP request step are in same testsuite and testcase. Please let me know if there is anything missing.



def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)


def request = testRunner.testCase.getTestStepByName( "HTTP_Test_Request" );
log.info("*********request values::::"+request)

def property = request.getProperty("request");
def records  = new groovy.util.XmlParser(false,false).parseText(property.value);
Thanks
Shiva

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Shiva,


    You code looks OK. The snippet:

    def request = testRunner.testCase.getTestStepByName( "HTTP_Test_Request" );
    log.info("*********request values::::"+request)

    should actually work from both UI and command-line (e.g. when testrunner.sh or testrunner.bat is invoked). It works on my machine.

    Make sure you've entered the test step name correctly. You can, for example, click on a test step you want to access, hit F2 (as if to rename it). copy the name in clipboard and paste it right into your Groovy script.

    If you're still getting a null, then download the latest nightly build and try the same script with it.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
  • Somehow my classpath was referring to soapui2.0.2 instead of 2.5. With 2.5 it works fine.
    Thanks