My testcase has multiple scenarios like listed below. Instead of using numbers with response1 and request1, I would like to use variable i and increment the i as I go along.
Because response is not a string, I can’t say response+i or responsei. I would appreciate some ideas on how to go about using variable i instead of using hard coded numbers.
Thanks in advance.
Current test Scenarios:
response1 = WS.sendRequestAndVerify(findTestObject(‘ABC/GetUserId’, [(‘UserId’) : “TestUser01”]))
request1 = WSResponseManager.getInstance().getCurrentRequest()
Thank you for the quick response. I understand what you are trying to say for the List. Howerver if I add my responses and
requests into a List then how would I set request name.
Originally, I had the following steps and I wanted to change it so I wouldn’t have to use the response1 and response2…etc
Now I’m changing how my response and request are saved by using List.
List response = []
List request = []
response.add( WS.sendRequestAndVerify(findTestObject(‘ABC/GetUserId’, [(‘UserId’) : “TestUser03”])))
request.add( WSResponseManager.getInstance().getCurrentRequest()) request.SetName(“CreateUser”) - this is what I don’t know how to do when using List
If you look at my thought bubble above, I showed how to display the requests and responses as Lists. So, rather than just the variable, you need the index as well. (Lists start at zero.)
No signature of method: com.kms.katalon.core.testobject.RequestObject.SetName() is applicable for argument types: (java.lang.String) values: [CreateUser] Possible solutions: setName(java.lang.String), getName(), getAt(java.lang.String)
Oh, the reference seems to be “setName” with a lowercase “s”, not a capital as you have it.
How about print out what you have in the List just to see if we have captured the references?
List response = []
List request = []
response.add(WS.sendRequestAndVerify(findTestObject('ABC/GetUserId', [('UserId') : "TestUser03"])))
request.add(WSResponseManager.getInstance().getCurrentRequest())
for (int i = 0 ; i < response.size(); i++) {
println(“your no. ${i} response is ${response[i]}”)
}
for (int i = 0 ; i < request.size(); i++) {
println("your no. ${i} request is ${request[i]}")
}
request.get(0).setName("CreateUser")