cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve all test steps using groovy script

SOLVED
Highlighted
Contributor

How to retrieve all test steps using groovy script

Hi Team,

 

I want to retrieve all the test steps from test case, Need to add headers to the each step.

 

Regards,

Karthik

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

Re: How to retrieve all test steps using groovy script

I'm sorry I haven't had experience of that so I can't really offer specific advice, but have a look at the Event Handling functionality:

 

https://support.smartbear.com/readyapi/docs/testing/handling-events.html

 

In particular the RequestFilter.filterRequest event. The recent version of ReadyAPI come with a sample script with the comment:

 

"// Sample event script to add custom HTTP header to all outgoing REST, SOAP and HTTP(S) calls"

 

This sounds like what you are after.

 

Edit: It was Version 2.4 which added the sample event handler scripts to new projects.

5 REPLIES 5
Super Contributor

Re: How to retrieve all test steps using groovy script

Not sure where you want to run the script from, but here is one that will run from a test case Setup Script:

 

testCase.getTestSteps().each(){testStepName, testStep  ->
	log.info(testStepName)
	log.info(testStep.getClass())
}
Contributor

Re: How to retrieve all test steps using groovy script

Thanks 

 

I want to take the Environment from the property that to Test case level.

Using that environment(int or staging). I need to set the Headers to all the test steps.

It has to work, if I run test step level also.

 

Regards,

Karthik

Super Contributor

Re: How to retrieve all test steps using groovy script

I'm sorry I haven't had experience of that so I can't really offer specific advice, but have a look at the Event Handling functionality:

 

https://support.smartbear.com/readyapi/docs/testing/handling-events.html

 

In particular the RequestFilter.filterRequest event. The recent version of ReadyAPI come with a sample script with the comment:

 

"// Sample event script to add custom HTTP header to all outgoing REST, SOAP and HTTP(S) calls"

 

This sounds like what you are after.

 

Edit: It was Version 2.4 which added the sample event handler scripts to new projects.

Community Hero

Re: How to retrieve all test steps using groovy script

You should follow what @Radford is suggested.

By the way, if headers are required, they must have been needed irrespective of environment. Only values changes depending on the environment.

If not comfortable with event handling, then It is also possible to achieve it in simple manner (tedious if there are lot of tests) by adding headers to the test steps and use property expansion as values(probably project level custom properties to store the header values) and change the property values as per the environment.


Regards,
Rao.
Contributor

Re: How to retrieve all test steps using groovy script

Thanks..!!

 

Regards,

Karthik

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors