[Webtest] New XPath

Soula, William Soula, William" <wsoula@pointserve.com
Tue, 8 Jul 2008 15:31:31 -0500


--_000_93B3B6122B906D44BC7E8B8CEFB0DBBB1844F457A5SGPEXCHANGEpo_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Actually, I don't think I have it correct.  I think what I thought was corr=
ect just evaluates to true regardless of it should, since I cannot set a ch=
eckbox doing it that way.

________________________________
From: Soula, William
Sent: Tuesday, July 08, 2008 1:04 PM
To: webtest@lists.canoo.com; Soula, William
Subject: RE: [Webtest] New XPath

Of course after I email the list I figure it out.  If I changed the second =
verifyXPath to wt:cleanText(td=3D'WATIR') it works correctly.  So the corre=
ct verifyXPath is: <verifyXPath xpath=3D"//tr[wt:cleanText(td=3D'WATIR')]"/=
>  I was going off Marc's post that said:
- spaces are not trimmed in text
ex: if the text of the above td is "  2.1", the XPath expression should
be changed to //tr[td/text() =3D '  2.1']. Alternatively you can use the
wt:cleanText function //tr[wt:cleanText(td) =3D '2.1']

and his example wasn't working for me.
________________________________
From: webtest-admin@lists.canoo.com [mailto:webtest-admin@lists.canoo.com] =
On Behalf Of Soula, William
Sent: Tuesday, July 08, 2008 12:42 PM
To: webtest@lists.canoo.com
Subject: [Webtest] New XPath

I have been trying to upgrade to the latest version of webtest and xpath ha=
s been giving me much trouble.  I think I have got it down to this problem:

<verifyXPath xpath=3D"wt:cleanText(//tr[td=3D'WATIR'])"/> -> Works
<verifyXPath xpath=3D"//tr[wt:cleanText(td)=3D'WATIR']"/> -> Doesn't Work

Why are these two xpaths evaluating differently?  The reason I want to know=
 is that I'm trying to verify the preceding sibling checkbox is checked and=
 I can't wrap the whole xpath in wt:cleanText, because "The xpath doesn't s=
elect an Element: 'class java.lang.String'".  Source code below:

<html>
<head>
  <title>Planning</title>
</head>
    <table id=3D"resourceSelectionTable" class=3D"data">
       <tr>
      <td><input type=3D"checkbox" name=3D"selectedResources" value=3D'1' o=
nClick=3D"resourceCheckboxEventHandler()" checked></td>
           <td>WATIR</td>
       </tr>
    </table>
</body>
</html>

--_000_93B3B6122B906D44BC7E8B8CEFB0DBBB1844F457A5SGPEXCHANGEpo_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.6000.16674" name=3DGENERATOR></HEAD>
<BODY>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D734473020-08072008><FONT face=3DA=
rial=20
color=3D#0000ff size=3D2>Actually, I don't think I have it correct.&nbsp; I=
 think=20
what I thought was correct just evaluates to true regardless of it should, =
since=20
I cannot set a checkbox doing it that way.</FONT></SPAN></DIV><BR>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B> Soula, William <BR><B>Sent:</B> T=
uesday,=20
July 08, 2008 1:04 PM<BR><B>To:</B> webtest@lists.canoo.com; Soula,=20
William<BR><B>Subject:</B> RE: [Webtest] New XPath<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D695505917-08072008><FONT face=3DA=
rial=20
color=3D#0000ff size=3D2>Of course after I email the list I figure it out.&=
nbsp; If=20
I changed the second verifyXPath to wt:cleanText(td=3D'WATIR') it works=20
correctly.&nbsp; So the correct verifyXPath is: &lt;verifyXPath=20
xpath=3D"//tr[wt:cleanText(td=3D'WATIR')]"/&gt;&nbsp; I was going off Marc'=
s post=20
that said: </FONT></SPAN></DIV>
<DIV dir=3Dltr align=3Dleft><SPAN class=3D695505917-08072008><SPAN>- spaces=
 are not=20
trimmed in text </SPAN><BR><SPAN>ex: if the text of the above td is "=20
&nbsp;2.1", the XPath expression should </SPAN><BR><SPAN>be changed to=20
//tr[td/text() =3D ' &nbsp;2.1']. Alternatively you can use the=20
</SPAN><BR><SPAN>wt:<B class=3Dhighlight>cleanText</B> function //tr[wt:<B=
=20
class=3Dhighlight>cleanText</B>(td) =3D '2.1'] </SPAN></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT color=3D#0000ff><FONT size=3D2>a<SPAN=20
class=3D695505917-08072008>nd his example wasn't working for=20
me.</SPAN></FONT></FONT></FONT><BR></DIV>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft>
<HR tabIndex=3D-1>
<FONT face=3DTahoma size=3D2><B>From:</B> webtest-admin@lists.canoo.com=20
[mailto:webtest-admin@lists.canoo.com] <B>On Behalf Of </B>Soula,=20
William<BR><B>Sent:</B> Tuesday, July 08, 2008 12:42 PM<BR><B>To:</B>=20
webtest@lists.canoo.com<BR><B>Subject:</B> [Webtest] New=20
XPath<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial size=3D2>I have be=
en trying=20
to upgrade to the latest version of webtest and xpath has been giving me mu=
ch=20
trouble.&nbsp; I think I have got it down to this problem:</FONT></SPAN></D=
IV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial size=3D2>&lt;verif=
yXPath=20
xpath=3D"wt:cleanText(//tr[td=3D'WATIR'])"/&gt; -&gt; Works<BR>&lt;verifyXP=
ath=20
xpath=3D"//tr[wt:cleanText(td)=3D'WATIR']"/&gt;&nbsp;-&gt; Doesn't=20
Work</FONT></SPAN></DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial size=3D2>Why are t=
hese two=20
xpaths evaluating differently?&nbsp; The reason I want to know is that I'm=
=20
trying to verify the preceding sibling checkbox is checked and I can't wrap=
 the=20
whole xpath in wt:cleanText, because "<FONT face=3D"Times New Roman" size=
=3D3>The=20
xpath doesn't select an Element: 'class java.lang.String'"</FONT>.&nbsp; So=
urce=20
code below:</FONT></SPAN></DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D905291117-08072008><FONT face=3DArial=20
size=3D2>&lt;html&gt;<BR>&lt;head&gt;<BR>&nbsp;=20
&lt;title&gt;Planning&lt;/title&gt;<BR>&lt;/head&gt;<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&lt;table=20
id=3D"resourceSelectionTable"=20
class=3D"data"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;input=20
type=3D"checkbox" name=3D"selectedResources" value=3D'1'=20
onClick=3D"resourceCheckboxEventHandler()"=20
checked&gt;&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;=20
&nbsp;&lt;td&gt;WATIR&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;/tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;<BR>&lt;/body&gt;<BR>&=
lt;/html&gt;</FONT></SPAN></DIV></BODY></HTML>

--_000_93B3B6122B906D44BC7E8B8CEFB0DBBB1844F457A5SGPEXCHANGEpo_--