cancel
Showing results for 
Search instead for 
Did you mean: 

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

Dear Community, API Masterminds week 4 has started!

Participate in the exciting online event by posting questions or replies and win! During the entire March, we decide top contributors each week and reward them with great gifts . Congratulate the winners of Week 3 here.
Week 4 task: Ask more questions, bring interesting topics and reply to existing ones in the ReadyAPI Community
Topics to participate in:
See All
Week 4 Leaders:
Members with the biggest number of posts
nmrao 18 posts
HimanshuTayal 17 posts
richie 2 posts
pizzaTime 1 posts
PratikshaMehete 1 posts
Highlighted
Contributor

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 2
Highlighted

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

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


 Join the 2020 API Masterminds event in the ReadyAPI Community to demonstrate your excellent expertise, help people and win prizes! Start participating today!
Highlighted
Contributor

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

Somehow my classpath was referring to soapui2.0.2 instead of 2.5. With 2.5 it works fine.
Thanks
New Here?
Join us and watch the welcome video:
Join 2020 API Masterminds
We invite all lovers of API testing to participate in the API Masterminds event. Ask questions or help others by giving solutions and get rewarded.
>> Participate Today
Get Your Free Ticket
SBC2020
Top Kudoed Authors