1

I'm trying to get some elements in a web page using webView.loadUrl(...);. However, I found out that there is a loading that "creates" these elements after the page is already loaded. So, I didn't find a way to get these. I tried to use onPageFinished but it doesn't look like it is called when the loading inside the web page finishes. I also tried to put a button that triggers the webView.loadUrl(...);. This tip only works if the user doesn't click too fast on the button, because then the loading doesn't have the time to finish before.
Here is a video of the page booting up, hoping for you to better understand what I mean by a loading inside the page : https://www.youtube.com/watch?v=q1267dcJai8&feature=youtu.be

If I haven't been clear enough, I'd be happy to clarify things further. Thank you in advance!
Edit : To clarify something, I'm not exactly asking for a way to get these elements. A way to delay the webView.loadUrl(...); while the webpage is loading would also be perfect for me.

MizuPanda
  • 11
  • 5

1 Answers1

0

Try onProgressChanged() of WebChromeClient like below.

Documentation link: https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)

            @Override
            public void onProgressChanged(WebView view, final int newProgress) {
                super.onProgressChanged(view, newProgress);

                   if (newProgress == 100) {
                       //Page load done
                   }
                   else
                   {
                      //Page is still loading wait...
                   }

            }
Chaitanya Karmarkar
  • 1,425
  • 2
  • 7
  • 18