There is a webview and a button. When the button is pressed, JS is executed.
webEngine.executeScript("document.querySelector(\"[data-bid='924']\").click()"); After you need to run another script, BUT after the trace loads. page (execution of the first script translates to another page).
webEngine.executeScript("document.querySelector(\"[href='#placeBet']\").click()"); The problem is that the second script is executed immediately, I tried to fix it by adding a listener:
wenEngine.getLoadWorker().stateProperty().addListener((obs, oldState, newState) -> { System.out.println(newState); String url = autoBetEngine.getLocation(); if(url.contains("addBet?")) { if (newState == Worker.State.SUCCEEDED) { autoBetEngine.executeScript("document.querySelector(\"[href='#placeBet']\").click()"); } } }); But it does not work at all when it goes to that page. This is a mobile version of the site, and there somehow see the transition works.
So, is there any listener who is watching the WebView URL change or not? How do I solve this problem? Thanks in advance for any advice.