开发者

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

开发者 https://www.devze.com 2023-02-08 20:20 出处:网络
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 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

精彩评论

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