Hello Jonathan

yes I know that what I ask for is little bit uncommon :-)

"In advance": normally I retieve a XPath with Firebug
and copy the result as shown below into e.g. verifyXPath
method. After that I run the test. Because the HTML output
of the server is identical the webtest ends successfully.

>Are you trying to determine the Xpath at test 
>time?

Yes, at least in principle. What I want to do is searching a page for a
given value.

Normally one sets up a test like this (see the fragment at the end):

          verifyXPath description: "check total qty",
          xpath: "/html/body/table/tbody/tr[4]/td[2]",
          text: "4"

In principle I like to do the inverse, asking for given
element value  ("4") the XPath:

          verifyText description: "check total qty",
          text: "4",
          xpath: "/html/body/table/tbody/tr[4]/td[2]"

This is of course the same as the previous test.

But I'm only interested  in if at least one XPath exists.
I would write that as

          verifyText description: "check total qty",
          text: "4"
      

Kind reagrds, Markus


<html>
<body>
<h1>Your Order</h1>
<table border='1' width='60%'>
  <tr><th>Item</th><th>Qty</th><th>Unit Price</th><th>Amount</th></tr>
    <tr class='lineitem'><td>Mouse
Pad</td><td>3</td><td>5</td><td>15</td></tr>
      <tr class='lineitem'><td>USB Memory Stick
512Mb</td><td>1</td><td>50</td><td>50</td></tr>
        <tr
class='total'><td>Total</td><td>4</td><td>&nbsp;</td><td>65</td></tr>
        </table>
</body>
</html>


On 08/02/2010 06:50 PM, Jonathan Rosenberg wrote:
> Markus,
>
> I have to admit that I don't understand what you're asking.  In particular
>
>   
>> Sometimes I do not know the XPath of an element in advance and I was
>>     
> searching for a
>   
>> method to retrieve the XPath for given attribute value.
>>     
> In "advance" of what?  Are you trying to determine the Xpath at test time?
>
>   
>> It is sufficient to know that a XPath exists. I do not need  necessarily
>>     
> to know the
>   
>> XPath itself.
>>     
> Can you rephrase this?  It doesn't make sense to me.
>
> --
> Jonathan Rosenberg
> Founder & Executive Director, Tabby's Place
> http://www.tabbysplace.org/
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Markus Wildi
> Sent: Monday, August 02, 2010 1:00 AM
> To: [email protected]
> Subject: [Webtest] reverse verifyXPath: verifyText
>
> Hello
>
> I'm quite new to canoo WebTest.
>
>  
> Sometimes I do not know the XPath of an element
> in advance and I was searching for a method to
> retrieve the XPath for given attribute value. It
> is sufficient to know that a XPath exists. I do
> not need  necessarily to know the XPath itself.
>
>
> That means instead of
> <verifyXPath description="simple match with value"
>         xpath="/html/head/title"
>         text="Canoo WebTest"/>
>
> something like
>
> <verifyText description="Test if an XPath exists"
>         text="Canoo WebTest"/>
>
> regardless if the text appears multiple times.
>
> Ragrads, Markus
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest
>
>   

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to