I want to add my javascript to the remote website.
I tried to use the method onPageFinished but it only get the website before the script run. The website has to get all data from server and I have to wait until it finished so I can add js to the generated element.
All elements I want to use have to wait until the script generate them
How can I know when the website has fully rendered? (ran all scripts and has all generated html)
EDIT
I can get the generated html but it can't help anything ( this )
I also tried many solutions but they didn't work (this and this)
Here my sample code
webPreviewDocument.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
webPreviewDocument.loadUrl("javascript:alert('Example');"); // just example
}
});
WebSettings webSettings = webPreviewDocument.getSettings();
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
webSettings.setLoadWithOverviewMode(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webPreviewDocument.loadUrl(mMaterialPreview.getPreviewUrl());
when onPageFinished called, the page is loading preview content, I have to wait few seconds and then to all the content loaded. I also tried to use sleep and wait for both js and java but it doesn't work