scenario:
There are two drop downs Street and House number on a same page. When we select a value in street drop down we get to see the available house numbers for that street in other drop down. We then select a house number and then proceed.
Issue:
Along with house numbers, we can see a addressId that is assigned to each house number in the response. The addressId appears in script based on the house number we select. How can i correlate this addressId as there are several addressIds in the response with the same boundaries. I cannot go for occurrence as when we select a different street, different set of house numbers with different addressIds' comes in response and the same occurrence selected of earlier addressId may not be valid for the house number which I selected now. Please let us know on this.
more info:
I need to correlate in the next request which comes immediately after the above mentioned response with addressids
I cannot see this address in application. so i cannot enter manually.
response file attached.
You could extract the addressId and the houseNumber at the same time to make sure that they will still be from the same selection.
For example, if you switch in advanced mode in the variable extractor panel and use that regexp: addressId":"(\d*?)".*?houseNumber":"(\d*?)"
As group value you can use $1$ and $2$.
It will extract both values at the same time. If i name my variable "Extractor", you can call them like this: ${Extractor_rand_g1} and ${Extractor_rand_g2} to get the AddressId and the right houseNumber. "rand" is to use a random value if you extracted all occurrences. It's just as example.
Now if you would like a specific houseNumber based on an adressId that you already know beforehand in your script, you can simply replace in the expression above "adressId" by your variable that contains the right addressId.
The regexp will not be evaluated in the variable extractor panel but during runtime your addressId will be correctly replaced by your value.
I hope it will help you.
Thanks Nouredine for the response. I have tried the below.
For eg. i need the addressID for house number: 22 (house no. is parametrized), so i have given the reg. expression as
addressId":"(\d*)".*?houseNumber":"(${Scenario2_ORT.HouseNo})"
House number is captured as 22 while execution. But the first addressID only(which addressID comes first in response; in this case addressID for H.No 1) is being fetched but not the one corresponding to H.No 22.
I used this with occurrence as 1. i didn't go for random as i need address ID for specific h.no's each time.
That regexp should work. It will limit the number of characters that is expected between addressId and houseNumber:
"addressId":"(\d*)".{10,150}houseNumber":"22"
Replace 22 by your variable and it should work.
Thank you that works..Please let me know what does 10 and 150 signify. what are those limits.?
Those limits are the number of characters that the regexp will seek after addressId. 10 is the minimum and 150 the maximum. I chose them but it is just an example, i could have used (1, 200) or any values that work.
Without those limits the regexp will match the first addressId until your houseNumber, that's why the first addressId occurence was picked up.