Oh forgot to mention this.

clickLinkWithText(String text, int k) will click on the kth link in the response which contains the provided text. So just use clickLinkWithText("Rooming list", 1) to click on the second link.

cheers
nilesh


On 3/7/06, Nilesh Trivedi <[EMAIL PROTECTED]> wrote:
Hi Rachel,

clickLinkWithText(String text) will find the first matching link which "contains" the provided text string. Hence, the first link gets clicked when you pass "Rooming list" as the link text.

There are two ways you can avoid this happening:
(1) do a getResponse().getLinkWithText("rooming list") which returns a WebLink, and verify that this link is the correct one before calling WebLink.click ().

(2) Set HttpUnitOptions.matchesIgnoreCase accordingly so that "Rooming list" with an uppercase "R" matches the second link only.

Try and let me know if it works. Even I am getting upto speed on jWebUnit.

cheers
nilesh



On 3/7/06, Rachel Swailes <[EMAIL PROTECTED]> wrote:
Hi there

I'm busy writing tests with JWebUnit to test a tapestry application that
we're writing.

On this specific page, there are (amongst other things) two links;

<a
href=""
rooming list</a>
<a
href="">list</a>

Now I am trying to click on the second link. When I try
clickLinkWithText("Rooming list") expecting the second link to be
clicked, the first link is in fact clicked. (I work this out by getting
the dialog and viewing the resultant html.) I have also tried looping
through all of the available links and clicking on the link that matches
the url. When I do this, no failures or exceptions are thrown, but it is
as if the link is not actually followed.

WebResponse webResponse = dialog.getResponse();
        boolean linkFound = false;
        try {
            WebLink[] webLinks = webResponse.getLinks();
            for(WebLink wl: webLinks){
                if(wl.getURLString().equals(url)){
                    wl.click();
                    linkFound = true;
                }
            }
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

If anyone has any suggestions as to how to get the second link clicked
it would be greatly appreciated.

Many thanks,
Rachel


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users


Reply via email to