Hi Markus,

...so you only want to check if an XPath exists?
I recently did the same in SoapUI and my XPath query there used the "exists()" 
function.
I am not sure if that is supported by webtest however... but then, aren't they 
basically all using the same libs? ;)

Someone else here on the forum may want to give more context?

Note:
I still don't understand why you want to use this approach... it doesn't sound 
like "correct" testing.
Example: If you say "a value of 4 must be somewhere": Yes, you can tell webtest 
to check that. But it's not exactly the right kind of requirement because if 
YOU look at the webpage manually and you see the "4" somewhere, you will say it 
is correct because the "4" is in a certain semantic context.
That "context" is missing if you tell webtest to check if there is a 4 
"somewhere". It might find (in a worst case) a "4" in a date, a phone number, 
an paging breadcrumb... whatever

So unless you tell me that you will be using a very "narrow" XPath into your 
website, I doubt the approach makes a lot of sense... sorry. ;)

HTH, Thomas

Thomas Klein
Senior Associate, QA | SapientNitro

________________________________________
From: [email protected] [[email protected]] On Behalf 
Of Markus Wildi [[email protected]]
Sent: Tuesday, August 03, 2010 12:37
To: [email protected]
Subject: Re: [Webtest] reverse verifyXPath: verifyText

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_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to