调用click后如何导航到另一个页面?
我试图获取所有主链接,然后单击它们并导航到页面:
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 表达式看起来不错吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道文档在 NetBeans 中如何工作,但文档都可以在线获取,并且 如果你访问它,你会看到返回类型是
,大部分情况下可能是 HtmlPage时间,但也可以是 XmlPage 或类似的东西。
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.