[Webtest] XPath: Absolut element location versus conditional branch (new in English)

Ammann Kuno webtest@lists.canoo.com
Wed, 27 Nov 2002 13:50:15 +0100


This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C29613.889297E8"

------_=_NextPart_001_01C29613.889297E8
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

hi all! i'm trying to introduce functional testings based on data
organized in tables with many cells in some rows. the html page to test
looks like this:
<HTML><HEAD><TITLE>PFFireForm</TITLE>
</HEAD><BODY BGCOLOR=3D"#FFFFFF">
<table border=3D"0" width=3D"80%">
   ....
</table>
<table id=3Ddata>
  <tr>
    <td>C003</td>
    <td>C004</td>
    <td>C007</td>
    <td>C008</td>
    <td>C009</td>
    ....
</tr>
  <tr>
    <td>001</td>
    <td>CH</td>
    <td>CHF</td>
    <td></td>
    <td>|CHF|ASIA|equity|CS_GROUP_N</td>
    ....
  </tr>
  <tr>
    <td>001</td>
    <td>CH</td>
    <td>CHF</td>
    <td></td>
    <td>|CHF|ASIA|equity|CS_GROUP_N</td>=20
    ....
  </tr>
  <tr>
    <td>001</td>
    <td>CH</td>
    <td>EUR</td>
    <td></td>
    <td>CH365|EUR|ASIA|bond|DAILY365</td>=20
    ....
  </tr>
</table>
</body>
</html>
=20
i'm interested only in the second table and created the following steps
to control the result (the following list of steps starts with some
baisc running steps, to show the way i used to check the possible steps
and build my target test step). the following steps are working as
expected:
=20
<verifytext stepid=3D"check ccy via table" text=3D"EUR">
 <table id=3D"data" row=3D"2" column=3D"2"/>
</verifytext>
<verifyxpath stepid=3D"check report table" xpath=3D"/html/body/table[2]"
regex=3D"false"/>
<verifyxpath stepid=3D"check 2" xpath=3D"/html/body/table[2]/tr[2]"
text=3D".*ASIA.*" regex=3D"true"/>
<verifyxpath stepid=3D"check 3" =
xpath=3D"/html/body/table[2]/tr[3]/td[3]"
text=3D"EUR" regex=3D"false"/>
=20
surprisingly the following step was working also (i expected the need of
text=3D".*ASIA.*"):
<verifyxpath stepid=3D"check 4" xpath=3D"/html/body/table[2]/tr[3]"
text=3D"ASIA" regex=3D"true"/>
=20
using the following two steps i tried to catch results of the xpath,
analysing the failure of the last step (see below). first i was
selecting all rows having a cell with EUR as content. the step feedback
was "...evaluates to: , expected value is: VV" (=3Dnothing found). this
result is not understandable to me: in step 3 above verifyxpath
confirmed that a cell with the value EUR is available exactly in row 3
cell 3 :-(
<verifyxpath stepid=3D"check 5" =
xpath=3D"/html/body/table[2]/tr[td=3DEUR]"
text=3D"VV" regex=3D"false"/>
=20
similar the following step is looking for any cell with value EUR (in
the whole document). also this step returns an unexpected failure, see
also check 5 above:
<verifyxpath stepid=3D"check 6" xpath=3D"//tr[td=3DEUR]" text=3D"VV"
regex=3D"false"/>
=20
the goal of all these basic steps is to build a step identifying a row
based on an identifying cell. in this located row i would like to
specify a functional check (the identifying cell in this example is not
shown of the example table above. instead also the cell value EUR could
be used to catch the correct row):
<verifyxpath stepid=3D"check C510 for bond daily365 "
xpath=3D"/html/body/table/tr[td=3DCH365]/td[3]" text=3D"EUR" =
regex=3D"false"/>
=20
would be nice to get any feedback or even guiding hints. or are there
any other possibilities to implement this functional test based on rows?
i also tried regular expression checks, but couldn't finish the needed
expression. the regular expression should stop before the finish of the
current html row so i startet with "CH365.*?EUR" but needed to exclude
any occurence of <tr>. leading me to something like "CH365[^tr]*?EUR"
which was not working as it generally stops before each occurence of the
character t or r (e.g. also before equity). it should be possible to
exclude explicit the word '<tr'.
thanks a lot for your support in advance and sorry for the german
version of my issue before, regards kuno

------_=_NextPart_001_01C29613.889297E8
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D389042409-27112002><SPAN=20
class=3D467080012-27112002>hi all! i'm trying to introduce functional =
testings=20
based on data organized in tables with many cells in some rows. the html =
page to=20
test looks like this:</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002>&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;PFFireFor=
m&lt;/TITLE&gt;<BR>&lt;/HEAD&gt;&lt;BODY=20
BGCOLOR=3D"#FFFFFF"&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&lt;table border=3D"0"=20
width=3D"80%"&gt;<BR>&nbsp;&nbsp; ....<BR>&lt;/table&gt;<BR>&lt;table=20
id=3Ddata&gt;<BR>&nbsp; &lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;C003&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;C004&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;C007&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;C008&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;C009&lt;/td&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;&nbsp;&nbsp;=20
....</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002>&lt;/tr&gt;<BR>&nbsp; =
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;001&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CH&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CHF&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;|CHF|ASIA|equity|CS_GROUP_N&lt;/td&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;&nbsp;&nbsp;=20
....</SPAN></FONT></DIV>
<DIV><FONT size=3D+0><SPAN class=3D389042409-27112002><FONT face=3DArial =
size=3D2>&nbsp;=20
&lt;/tr&gt;<BR>&nbsp; &lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;001&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CH&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CHF&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;|CHF|ASIA|equity|CS_GROUP_N&lt;/td&gt;</FONT>=20
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;&nbsp;&nbsp;=20
....</SPAN></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;=20
&lt;/tr&gt;</SPAN><BR>&nbsp; &lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;001&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CH&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp; &lt;td&gt;<SPAN=20
class=3D389042409-27112002>EUR</SPAN>&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;=20
&lt;td&gt;CH365|EUR|ASIA|bond|DAILY365&lt;/td&gt;</FONT></FONT>=20
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;&nbsp;&nbsp;=20
....</SPAN></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN =
class=3D389042409-27112002>&nbsp;=20
&lt;/tr&gt;</SPAN><BR>&lt;/table&gt;</FONT></FONT></SPAN></FONT></DIV></D=
IV></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002>&lt;/body&gt;<BR>&lt;/html&gt;</SPAN></FONT></=
DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D389042409-27112002><SPAN=20
class=3D467080012-27112002>i'm interested only in the second table and =
created the=20
following steps to control the result (the following list of steps =
starts with=20
some baisc running steps, to show the way i used to check the possible =
steps and=20
build my target test step). the following steps are working as=20
expected:</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&lt;verifytext=20
stepid=3D"check ccy via table" text=3D"EUR"&gt;<BR>&nbsp;&lt;table =
id=3D"data" row=3D"2"=20
column=3D"2"/&gt;<BR>&lt;/verifytext&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&lt;verifyxpath=20
stepid=3D"check report table" xpath=3D"/html/body/table[2]"=20
regex=3D"false"/&gt;<BR>&lt;verifyxpath stepid=3D"check 2"=20
xpath=3D"/html/body/table[2]/tr[2]" text=3D".*ASIA.*"=20
regex=3D"true"/&gt;<BR>&lt;verifyxpath stepid=3D"check 3"=20
xpath=3D"/html/body/table[2]/tr[3]/td[3]" text=3D"EUR"=20
regex=3D"false"/&gt;</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D389042409-27112002><SPAN=20
class=3D467080012-27112002>surprisingly the following step was working =
also (i=20
expected the need of&nbsp;text=3D".*ASIA.*"):</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D389042409-27112002>&lt;verifyxpath=20
stepid=3D"check 4" xpath=3D"/html/body/table[2]/tr[3]" text=3D"ASIA"=20
regex=3D"true"/&gt;</SPAN></FONT></DIV>
<DIV><FONT size=3D+0><SPAN class=3D389042409-27112002><FONT face=3DArial =
size=3D2><SPAN=20
class=3D389042409-27112002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT><SPAN class=3D389042409-27112002></SPAN><SPAN=20
class=3D467080012-27112002></SPAN><FONT face=3DArial size=3D2>u<SPAN=20
class=3D467080012-27112002>sing the following two steps i tried to catch =
results=20
of the xpath, analysing the failure of the last step (see below). first =
i was=20
selecting all rows having a cell with EUR as content. the step feedback =
was=20
"...evaluates to: , expected value is: VV" (=3Dnothing found).&nbsp;this =
result is=20
not understandable to me: in step 3 above verifyxpath confirmed that a =
cell with=20
the value EUR is available exactly in row 3 cell 3 =
:-(</SPAN><BR>&lt;verifyxpath=20
stepid=3D"check 5" xpath=3D"/html/body/table[2]/tr[td=3DEUR]" =
text=3D"VV"=20
regex=3D"false"/&gt;</FONT></FONT></DIV>
<DIV><FONT size=3D+0><FONT face=3DArial size=3D2><SPAN=20
class=3D389042409-27112002></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT><FONT><SPAN class=3D389042409-27112002></SPAN><SPAN=20
class=3D467080012-27112002></SPAN><FONT face=3DArial size=3D2>s<SPAN=20
class=3D467080012-27112002>imilar the following step is looking for any =
cell with=20
value EUR (in the whole document). also this step returns an=20
unexpected&nbsp;failure, see also check 5 =
above:</SPAN><BR>&lt;verifyxpath=20
stepid=3D"check 6" xpath=3D"//tr[td=3DEUR]" text=3D"VV"=20
regex=3D"false"/&gt;</FONT></FONT></FONT></DIV>
<DIV><FONT size=3D+0><FONT size=3D+0><SPAN =
class=3D389042409-27112002><FONT face=3DArial=20
size=3D2></FONT></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=3D+0><FONT size=3D+0><SPAN =
class=3D389042409-27112002></SPAN><SPAN=20
class=3D467080012-27112002></SPAN><FONT face=3DArial><FONT =
size=3D2>t<SPAN=20
class=3D467080012-27112002>he goal of all these basic steps is to build =
a step=20
identifying a row based on an identifying cell. in this located row i =
would like=20
to specify a functional check (the identifying cell in this example is =
not shown=20
of the example table above. instead also the cell value EUR could be =
used to=20
catch the correct row):</SPAN></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT size=3D+0><FONT size=3D+0><FONT face=3DArial><FONT =
size=3D2><SPAN=20
class=3D467080012-27112002></SPAN></FONT></FONT><FONT face=3DArial=20
size=3D2>&lt;verifyxpath stepid=3D"check C510 for bond daily365 "=20
xpath=3D"/html/body/table/tr[td=3DCH365]/td[3]"=20
text=3D"EUR"&nbsp;regex=3D"false"/&gt;</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D467080012-27112002><FONT face=3DArial size=3D2>would =
be nice to get=20
any feedback or even guiding hints. or are there any other possibilities =
to=20
implement this functional test based on rows? i also tried regular =
expression=20
checks, but couldn't finish the needed expression. the regular =
expression should=20
stop before the finish of the current html row so i startet with =
"CH365.*?EUR"=20
but needed to exclude any occurence of &lt;tr&gt;. leading me to =
something like=20
"CH365[^tr]*?EUR" which was not working as it generally stops before =
each=20
occurence of the character t or r (e.g. also before equity). it should =
be=20
possible to exclude explicit the word '&lt;tr'.</FONT></SPAN></DIV>
<DIV><SPAN class=3D467080012-27112002><FONT face=3DArial size=3D2>thanks =
a lot for=20
your support in advance and sorry for the german version of my issue =
before,=20
regards kuno</FONT></SPAN></SPAN></FONT></DIV></BODY></HTML>
=00
------_=_NextPart_001_01C29613.889297E8--

--------------InterScan_NT_MIME_Boundary--