Hi,
I am using this regex:
BOOKING REFERENCE.+((\r\n).+){2}\r\n[^>]*.([^<]+)
to extract the booking reference (EAMPXH) out of this page (simplified):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>Air New Zealand Bookings - Booking Confirmation</title></head><body>
<div id="main" style="display: block;">
<div class="i20">
<div class="panel">
<div class="paneltext">BOOKING REFERENCE</div>
</div>
<div class="indentcell">
<div class="errorstyle" style="font-family:
Arial,Verdana,Helvetica,sans-serif; font-style: normal; font-variant:
normal; font-weight: bold; font-size: 14px; line-height: normal;
font-size-adjust: none; font-stretch: normal;">EAMPXH</div>
</div>
</body></html>
When I put the regex into QuickREx in eclipse, it highlight up to the end of
the reference, and when I click through the groups at the bottom it gives me
this as the 3rd group.
However, when I do this in my WebTest script:
<storeRegEx
description="Extract confirmation number i.e. PNR Ref"
text="BOOKING
REFERENCE.+((\r\n).+){2}\r\n[^>]*.([^<]+)"
group="3"
property="PNR_Ref" />
<echo message="PNR Ref of #{PNR_Ref}" />
The result I get is just the ">" character.
The results.xml shows:
<step>
<parameter name="description" value="Extract confirmation
number i.e. PNR Ref"/>
<parameter name="group" value="3"/>
<parameter name="property" value="PNR_Ref"/>
<parameter name="taskName" value="storeRegEx"/>
<parameter name="text" value="BOOKING
REFERENCE.+((\r\n).+){2}\r\n[^>]*.([^<]+)"/>
<result>
<completed duration="16"/>
</result>
</step>
<step>
<parameter name="message" value="PNR Ref of >"/>
<parameter name="taskName" value="echo"/>
<result>
<completed duration="0"/>
</result>
</step>
I turned logs to debug and the relevant output is:
[storeRegEx] DEBUG (com.canoo.webtest.reporting.StepExecutionListener) -
isToIgnore: [EMAIL PROTECTED], main
[storeRegEx] DEBUG (com.canoo.webtest.reporting.StepResult) - In
retrieveNestedText
[storeRegEx] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step:
storeRegEx "Extract confirmation number i.e. PNR Ref" (8/10)
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - Executing storeRegEx
"Extract confirmation number i.e. PNR Ref" (8/10)
[storeRegEx] DEBUG (com.gargoylesoftware.htmlunit.WebResponseImpl) - No
charset specified in header, trying to guess it from content
[storeRegEx] DEBUG (com.gargoylesoftware.htmlunit.WebResponseImpl) - Nothing
guessed, supposing that it is ISO-8859-1
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - setWebtestProperty:
PNR_Ref=> [null]
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - Finished storeRegEx
"Extract confirmation number i.e. PNR Ref" (8/10)
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - Completed Step:
storeRegEx "Extract confirmation number i.e. PNR Ref" (8/10)
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - Step didn't produce
results, no need to notifying listeners
[storeRegEx] DEBUG (com.canoo.webtest.steps.Step) - <<<< Successful Step:
storeRegEx "Extract confirmation number i.e. PNR Ref" (8/10)
I've spent a good few hours trying things with no success so I'd be grateful
if anyone could advise me on what to do as I'm starting to look pretty
stupid here at work!
Incidentally, the response from the invoke saved during the test is
identical to the input file.
Please don't suggest using storeXPath as an alternative as the reason I
turned to storeRegEx was because of problems with storeXPath - I'll post
that separately!
I am using version R_1498
regards,
John