How to listen to the "page loaded after the redirect event" in WebEngine?

I am trying to automate downloading a JDK distribution from oracle.com using WebEngine / WebView and problems with redirect processing on one of the pages. The problem is that it does not generate any events that I know of when the page loads.

I track the redirect that occurs with webEngine.locationProperty(), so when this property changes, I notice that the redirection is happening. But it is not followed by a change webEngine.getLoadWorker().stateProperty(), and the required item does not load.

I solved the problem by starting a thread that watches my specific element appear by running the jQuery selector, i.e. webEngine.executeScript("$('#sso_username').length > 0").

Is there a better way to do this, it can happen that some property changes when the page after the redirect is loaded?

+4
source share

Source: https://habr.com/ru/post/1523403/


All Articles