I got this to work:

    String FIRST_ITEM_XPATH = "//t...@class='listItem'][1]/a/text()"
    def uri

    def clickListLink(int count) {
        ant.group(description:"Click the first ContextConfig list link.") {
            storeXPath( description:"Extract FIRST_ITEM_XPATH of first link
on page",
                        xpath:
"//t...@class='listItem']["+count+"]/a/text()",
                        property: "uri")
            clickLink(label: "#{uri}")
            verifyText(text:'Show ContextConfig', description:'Detail page')
        }
    }


---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://www.baselogic.com
Linked IN: http://linkedin.com/in/mickknutson
Twitter: http://twitter.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---



On Mon, Mar 15, 2010 at 4:25 AM, Florent Blondeau <[email protected]>wrote:

>  Hi Mick,
>
> you should take a look at <storeXPath> which store the result of an xpath
> evaluation in a variable
> that you can use later in your test script
>
> Cheers
>
> Florent
>
> Pingwy
> 27, rue des arènes
> 49100 Angers
>
>
>
> Mick Knutson a écrit :
>
> I have an XPath Value:
> String FIRST_ITEM_XPATH = "text(//t...@class='listItem',
> first()]/a[first()])"
>
>
> Here is the generated html on the page I am testing that I want to get:
>
>                     <tbody>
>                         <tr class="odd">
>
>
>                             <td class="listItem"><a 
> href="/divr/contextConfig/show/1">*1*</a></td>
>
>
>                             <td></td>
>                             
> <td>performDeviceRefreshBySerialNumber_CTIMEOUT</td>
>
>
>                             <td>10</td>
>                             <td></td>
>
>
>                         </tr>
>
>
>
>
> Basically, I want the Name of the first link so I can click that link.
>
> How can I assign this to a variable, then us it like:
>
> clickLink(label:'${firstLink}') // or something like this...?
>
>
>
> ---
> Thank You…
>
> Mick Knutson, President
>
> BASE Logic, Inc.
> Enterprise Architecture, Design, Mentoring & Agile Consulting
> p. (866) BLiNC-411: (254-6241-1)
> f. (415) 685-4233
>
> Website: http://www.baselogic.com
> Linked IN: http://linkedin.com/in/mickknutson
> Twitter: http://twitter.com/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
> ---
>
>

Reply via email to