Forum Discussion
- HimanshuTayalCommunity Hero
hi ABCDEFG
You can use below code for finding Endpoint and Resource Path
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")Do Like if you Find the Solution
Thanks,
Himanshu Tayal
- ABCDEFGContributor
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,
- HimanshuTayalCommunity Hero
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
Related Content
Recent Discussions
- 10 days ago