→ Gentoken (token done) → gives token
→ Create item with (token + Bearer) → give itemid in response
storing it in id Global variable in Create Item test case
3rd test case
→ My Next request is GET with Bearer token ${RESOURCE_URL}/item/${id}
How to verify the that value is same in request as saving “itemid” value in guid and compare it with “itemid” from response ?
def slurper = new groovy.json.JsonSlurper()
def result = slurper.parseText(response.getResponseBodyContent())
def guid = result.itemId
println(guid)
**WS.verifyMatch('itemId', guid, true)**
Getting error
Actual text ‘itemid’ and expected text ‘329097ab-asd-47cc-9873-234dasd6f2fa’ are not matched using regular expression
but in the response json looks like you have Itemid. Note that properties are case sensitive, using slurper will generate a map with the key having exact the same name as in the response.
Also, from the error Actual text ‘itemid’ ... looks like you passed something wrong to this method.
I am not sure how the verifyMatch keyword is working (cannot find it in API doc), but i think in for your case have to pass a variable there, not the text ‘itemId’ … sort of:
WS.verifyMatch(guid, id, true) //.e.g compare the value of retrieved variable `guid` with the value of global variable `id` used in the query
or, you can use verifyElementText instead (without parsing the result)
my current variable =lnguid
my global variable in previous test script = guid
Want to compare my values from response are same
“lnguid” = “guid” like this (which would be accurate with the scope WS.verifyMatch(lnguid, guid, true) (this doesn't works)
So instead WS.verifyElementPropertyValue(response, "itemId", id)