Am 22.06.2017 09:06, schrieb praveen tiwari:
Hi Felix,
Please find below an explanation in more detail:
HTML Response:
I have simplified the html to the following code:
<html>
<body>
<input name="fare1" value="id-1" />
<input name="in1" id="id-1-a" />
<input name="in1" id="id-1-b" />
<input name="out1" id="id-1-c" />
<input name="out1" id="id-1-d" />
<input name="fare2" value="id-2" />
<input name="in2" id="id-2-a" />
<input name="in2" id="id-2-b" />
<input name="out2" id="id-2-c" />
<input name="out2" id="id-2-d" />
</body>
</html>
fare1 and fare2 are your fare-ids and inX and outX are the inbound and
outbound parameters.
------------------------------------------------------------
------------------------------------------------------------
-------------------------------------
*FareID1:*
<input type="radio" name="timeoutbound1" value=""
id="ae3dc705-d5dc-4729-9288-133e036c1cda"
optid="ae3dc705-d5dc-4729-9288-133e036c1cda" />
<input type="radio" name="timeoutbound1" value=""
id="22c7814f-e145-4082-86a2-09c2f922b893"
...
<input type="radio" name="timeinbound1" value=""
id="5852bc68-461e-4570-b5ea-fb85f4367c18"
optid="5852bc68-461e-4570-b5ea-fb85f4367c18" />
<input id="fareRefId_1" name="FareRefId" type="hidden"
value="7f9a6381-9569-4af2-884f-16dd39332a9a" />
*FareID2:*
<input type="radio" name="timeoutbound2" value=""
id="ae3dc705-d5dc-4729-9288-133e036c1cda"
optid="ae3dc705-d5dc-4729-9288-133e036c1cda" />
<input type="radio" name="timeoutbound2" value=""
id="22c7814f-e145-4082-86a2-09c2f922b893"
...
<input type="radio" name="timeinbound2" value=""
id="f2a18f88-e87f-47f7-a31a-1cc92b905348"
optid="f2a18f88-e87f-47f7-a31a-1cc92b905348" />
<input type="radio" name="timeinbound2" value=""
id="dae19c11-dfa3-4483-8c0c-b06f0ec28c07"
optid="dae19c11-dfa3-4483-8c0c-b06f0ec28c07" />
<input id="fareRefId_2" name="FareRefId" type="hidden"
value="7f9a6381-9569-4af2-884f-16dd39332a9a" />
------------------------------------------------------------
------------------------------------------------------------
-------------------------------------
For "*fareRefId_1*" there are* multiple values of "timeinbound1" and
"timeoutbound1". *
For "*fareRefId_2*" there are* multiple values of "timeinbound2" and
"timeoutbound2". *
Similarilty there are multiple "fareRefId_No." in my response.
Scenario is that I need to extract value of "timeinbound" and
"timeoutbound"
depending on the value of fareRefId_No.
e.g. if fareRefId_2 - pass any value of "timeinbound2" and
"timeoutbound2".
fareRefId_9 - pass any value of "timeinbound9" and "timeoutbound9".
So you have a loop with a counter that you can reference as ${counter}
that counts from 1 to 2.
- controller loop
- config counter
- sampler http
- extractor (fare)
- extractor (in)
You are using a regex extractor in your example, but I think you are
better of using a css/jquery extractor:
For extractor (fare) the config woukd be:
reference name: fare
expression: input[name='fare${counter}']
attribute: value
match no.: 1
For extractor (in) you would use:
reference name: in
expression: input[name='in${counter}']
attribute: id
match no.: -1
This setup should give you the following variables and their respective
values:
counter=X
fare=id-X
in_1=id-X-a
in_2=id-X-b
in_MatchNr=2
It should be straightforward to extend the tests for include outX
The same can be accomplished with regex extractors and setting the
"match no." to the same values as above. But I think css extractor is
easier to get right.
Hope this helps,
Felix
I have added a "counter" config element in a while loop before calling
the
request containing below regular expression.
*Counter Config Element:*
Start: 2
Increment: 1
Reference name: Count
*Regular Expression used:*
Variable: FareReferenceId
Reg Exp: <input id="fareRefId_(.+?)" name="FareRefId" type="hidden"
value="(.+?)" />
Template: $1$$2$
Match No. ${Count}
Variable Passed: ${FareReferenceId_g2}
Variable: Timeinbound
Reg Exp: <input type="radio" name="timeinbound(.+?)" value=""
id="(.+?)"
optid
Template: $1$$2$
Match No. ${Count}
Variable Passed: ${Timeinbound_g2}
Variable: Timeoutbound
Reg Exp: <input type="radio" name="timeoutbound(.+?)" value=""
id="(.+?)"
optid
Template: $1$$2$
Match No. ${Count}
Variable Passed: ${Timeoutbound_g2}
Issue I am facing is that if counter = 2, it passed 2nd value of
fareRefId,
Timeinbound and TimeOutbound, while I need if counter = 2, it should
pass
second value of fareRefId and any value of Timeinbound2 and
TimeOutbound2,
Please let me know if you need more information.
On 22-Jun-2017 11:06 am, "Felix Schumacher" <
[email protected]> wrote:
Am 21. Juni 2017 18:31:43 MESZ schrieb praveen tiwari <
[email protected]>:
>Hi All,
>
>I have a scenario as below and seeking for help on same.
>
>I have a request and it's response contains data as below which I am
>able
>to extract using regular expression:
>
>For
>Fare 1
What is fare? I don't understand it?
>ABC 1, ABC 1, ABC 1 (multiple times)
Is ABC 1, ABC 1, ABC 1 already multiple times, or is it three times x
ABC 1
Maybe you could give a more concrete example with?
>XYZ 1, XYZ 1, XYZ 1 (multiple times)
>
>Fare 2
>ABC 2, ABC 2, ABC 2 (multiple times)
>XYZ 2, XYZ 2, XYZ 2 (multiple times)
>
>Fare n
>ABC n, ABC n, ABC n (multiple times)
>XYZ n, XYZ n, XYZ n (multiple times)
>
>Required scenario is:
>when I am getting fare 1, I need to select ABC 1 and XYZ 1.
>when I am getting fare 2, I need to select ABC 2 and XYZ 2.
>when I am getting fare n, I need to select ABC n and XYZ n.
>
>Problem I am facing is I am able to fetch "fare n" but when same number
>(n)
>is applied on ABC/XYZ in regular expression (templates), I am getting
>value
>from different fare section. e.g if I consider fare 2 (defined number
>in
>regexp template is 2), I am getting 2nd value from Fare 1 (ABC 1 and
>XYZ 1
>which is at 2nd position).
I don't understand the description. Could you give the concrete regex
and
templates you are using?
Regards,
Felix
>
>Any help with implementation of above login would be highly
>appreciated.
>If required more details, please let me know.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]