Forum Discussion
Thank you HimanshuTayal for the response.
I tried this in my test case (having only 1 test step) and getting this error message. Could you check this out?
java.lang.NullPointerException: Cannot invoke method getPropertyValue() on null object error at line: 1
Once above issue is resolved, i have another question: Suppose if i want to use this in multiple test steps included test case; how would this script identify the test step which i need to this script to identify?
Thanks in advance
Thanks,
Hi ABCDEFG
The code i have given to you, please replace
def endpoint = context.testCase.getTestStepByName("Request").getPropertyValue("Endpoint") def resourcePath = context.testCase.getTestStepByName("Request").resource
def data = endpoint + "/" + resourcePath def file = new File("D:/test.txt").write(data.toString(),"UTF-8")
The part i have BOLD, from the name of your request
And the answer to your second question is, just replace the Request with the Steps name you are having or you can apply loops as well on the Test Case.
Do Like and Accept if you Find the Solution
Thanks,
Himanshu Tayal
- ABCDEFG6 years agoContributor
Great HimanshuTayal. its working.
however when retrieving the 'resourcePath' path; its having a veribiage "RestResource:" right infront of the resource path, Do you know how to get the resourcepath with out this verbiage?
sample response == 'RestResource: /cloud-services/api/test/v1/health'
Else i have to write another block of code to trim it.
Thanks!