Adi Mor
Adi Mor

Reputation: 2165

SoapUI print full URL path of rest request using groovy

I'm using soapui with groovy script step I want to print the full url of my REST request. I tried using:

myFile.append(  testRunner.testCase.testSteps["My Test Name"].getProperty( "requestUri" ));

and I got null.

Upvotes: 2

Views: 5104

Answers (2)

shashi singh
shashi singh

Reputation: 104

The below is working fine for me. you can use the same code just need to change your step name.

Note: Make sure your same Test step should have run prior to below code.else you will get the error

[Cannot invoke method getURL() on null object], see error log for details.

Working Code:

def tr=testRunner.testCase.getTestStepByName("TriggerRequestTransactionsReportsService_V)
def String endPointUrlSave= tr.getHttpRequest().getResponse().getURL(); 
log.info "Your EndpointUrl is : " + endPointUrlSave;

Upvotes: 1

nwill001
nwill001

Reputation: 745

You will not be able to see the request info from a test step groovy script. However, the groovy script assertion has access to that information.

You can use this to easily retrieve the full endpoint:

def endpoint = messageExchange.getEndpoint()

Upvotes: 1

Related Questions