Tutorial :How to navigate to another page after calling click?


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?


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »