1

I have written some code using ui4j, and it has redirected to another page. I need to extract the URL from the current page.

BrowserEngine browser = BrowserFactory.getWebKit();
Page page = browser.navigate("somewebsite");
//some oprations have been perfomed
//need to extract the URL

1 Answers1

2

You could use the JavaScript capabilities of ui4j:

public static void main(final String[] args) {
  try (final Page page = getWebKit().navigate("http://www.xing.de")) {
    System.out.println("Example: " + page.executeScript("window.location.href"));
  }
}

The output for this particular example would be:

Example: https://www.xing.com/de
philonous
  • 3,621
  • 3
  • 27
  • 24