java - fill form programmatically in Android Webview - JavaScript -


I am trying to fill the form automatically from my school's website. I have seen some ways with javascript

Here is my code:

  @Override protected Zero onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState); SetContentView (R.layout.navegador_siiau_layout); Navegador_siiau = (webview) Find VVBiID (R.DDWWI_NEVEVER_SIU); Navegador_siiau.getSettings () setJavaScriptEnabled (true). Navegador_siiau.loadUrl ("http://siiauescolar.siiau.udg.mx/wus/gupprincipal.inicio"); Document.getElementsByName ('p_codigo_c'); String pwd = "FENMAA"; View.loadUrl ("JavaScript navegador_siiau.setWebViewClient (the new WebViewClient () {Public Zero (for viewing WebView, string URL) {string user =" 207,512,134 "onPageFinished.value = '" + user + "'; document.getElementsByName (' P_clave_c '). Value =' "+ pwd +" '; ");}}); }  

The result is an empty page, whose final string I try to put in the form ... What can I do to fill out the form and submit it correctly?

"itemprop =" text ">

This is untested, but I see two things wrong here:

  1. You should call setVebViewClient with your WebViewClient implementation before calling loadUrl . However, loadUrl then it probably will not make a difference, but it is worth a try that I think.

  2. You are not calling, asynchronous super.onPageFinished (see, url); You must add this call to InPageFinished

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 separate frame, so you actually have to call getElementsByName on a separate document, both the information that you want in the frame is located, the name in your page The

main frame is. So, if you can write javascript like this and load that in WebView as you should be up to:.

  window.frames ["mainframe"] document. GetElementsByName ('p_codigo_c') [0] .value = "user"; Window.frames ["mainframe"] Document. GetElementsByName ('p_clave_c') [0] .value = "password";  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -