2

In my application, after button click from one page context, the page actually will be rendered/loaded twice: 1) from url specified by button or form 2) page redirection from server side by HTTP 304, in this case, unless I have current thread sleep from several seconds, the element query will throw NullPointException. Here is the scenario. I am just wondering if there is anyway sleep() can be avoided, like event handler or something. I see there is onload in DocumentListener, could it possible to have unload in WindowListener or something?

try (Page page = browserEngine.navigate(LOGIN_URL)) { 

    element.click();

    // 1. page location is login_url
    // 2. page location is redirected to account overview
    TimeUnit.SECONDS.sleep(3).
    Document doc = page.getDocument();
    doc.query("something").get();
}
Frank
  • 49
  • 3

1 Answers1

1

The library's owner posted a solution, it works great for me: https://github.com/ui4j/ui4j/blob/master/ui4j-sample/src/main/java/com/ui4j/sample/RedirectAndWaitExample.java

Frank
  • 49
  • 3