I\'m trying to automatically fill a form from the website of my school. I\'ve seen some ways to do with javascrip.
Here is my code:
@Override
prote
This is untested, but I see two things wrong here:
You should call setWebViewClient
with your WebViewClient
implementation before you call loadUrl
. However, loadUrl
is asynchronous, so it probably would not make a difference, but this is worth a try I think.
You are not calling super.onPageFinished(view, url);
in onPageFinshed. You should add this call.
EDIT 2:
I finally took a look at the actual page you are working with. The problem is that the page loads content in a different frame, so you actually have to make the getElementsByName
call on a different document. The frame in which both of the inputs you want are located has the name mainFrame
in your page. So, you should write the javascript like this and load that into the WebView
as you have done above:
window.frames["mainFrame"].document.
getElementsByName('p_codigo_c')[0].value = "user";
window.frames["mainFrame"].document.
getElementsByName('p_clave_c')[0].value = "password";