tags:

views:

75

answers:

1

I am trying to get all the main links, then click on them and navigation to the page:

    WebClient client = new WebClient();

    HtmlPage page = client.getPage(url);

    // Get all links with a href of www.example.com/pages/1_

    List<HtmlAnchor> links = (List<HtmlAnchor>) page.getByXPath("//a[href='www.example.com/pages/1_*'");

    links[0].click();

After calling click, does it return a HtmlPage? (The NetBeans documentation is not telling me.)

Does the XPath expression look OK?

+1  A: 

I don't know how documentation works in NetBeans but the documentation is all available online, and if you go to it, you'll see that the return type is <P extends Page> which will probably be HtmlPage most of the time, but could also be XmlPage or something like that.

Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.

MatrixFrog