我试图获取所有主要链接,然后单击它们并导航到该页面:
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();
调用click后,是否返回一个HtmlPage? (NetBeans 文档没有告诉我。)
XPath 是吗?表情看起来还好吗?
最佳答案
我不知道文档在 NetBeans 中如何工作,但文档都可以在线获取,并且 if you go to it ,你会看到返回类型是 <P extends Page>
大多数时候可能是 HtmlPage,但也可能是 XmlPage 或类似的东西。
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.
关于java - 调用click后如何导航到另一个页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2008600/