Ask a Question

get teststep name/label

SOLVED
Kimdongart1
New Contributor

get teststep name/label

Hi. 

Im pretty new to this, so i need to ask. Have googled alot, but no answer. 

 

Problem: 

"Save/export request and response as file into folder"

I have a groove script i found via google search, that provide me with the correct setup. But it saves the files with  the testCase name, and not the testStep name. 

I was wondering if there are some way to get testStep name. 

 

------------ My current script ---------------

String tcName = testRunner.testCase.getName()

 

File req = new File("filePath" + tcName + "_request.xml")

File res = new File("filePath" + tcName + "_response.xml")

 

req.write context.expand('${"RequestName"#Request}')

res.write context.expand('${"ResponseName"#Response}')

------------------------------

 

This saves files in folder as "tcName_request.xml" and "tcName_response.xml" , but would like to have them as "testStepName_request.xml" and "testStepName_response.xml"

2 REPLIES 2
JoostDG
Frequent Contributor

Hi @Kimdongart1 ,

 

See my reply in recent topic https://community.smartbear.com/t5/ReadyAPI-Questions/Get-test-step-name-via-property-expansion-in-g...

 

To get a test step name you could just type "testRunner.testCase.getTestStep" followed by a "Ctrl+space" to see the autocomplete options:

JoostDG_0-1674812508293.png

So:

String testStepNameStep1 = testRunner.testCase.getTestStepAt(0).getName()

File req = new File("filePath" + testStepNameStep1 + "_request.xml")

File res = new File("filePath" + testStepNameStep1 + "_response.xml")

 

Hi @JoostDG 

Thanks alot

that helped in those cases where i only have a couple of steps. But when run it on large tc's with multiple steps, it gets difficult.. I have aprox. 400 TC's, some with up to 10 steps.. 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: