开发者

Given an HtmlUnit HtmlPage object, how do I get the URI of its Document?

The page object I have is the result of a long chain of click() calls (just in case you were wondering how I could have a page object without knowing the URL used to obtain it).

  • The method HtmlPage.getDocumentURI is not implemented.
  • Htm开发者_如何学PythonlPage.getOwnerDocument returns null.
  • page.executeJavaScript("return document.location").getJavaScriptResult() also returns null.

Any hints?


The answer is of course to realize that executeJavaScript should have been called evalJavaScript, and write something like

page.executeJavaScript("document.location").getJavaScriptResult()


page.getUrl()

worked fine for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜