Fill fields in webview automatically

前端 未结 6 1709
小蘑菇
小蘑菇 2020-11-27 04:26

I have seen this question floating around the internet, but I haven\'t found a working solution yet. Basically, I want to load my app and press a button; the button action w

6条回答
  •  难免孤独
    2020-11-27 05:15

    You don't need to use "java commands"... but instead JavaScript... for instance:

    String username = "cristian";
    webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");
    

    So basically, what you have to do is a big string of JavaScript code that will get those fields and put values on them; also, you can enable/disable the submit button from JavaScript.

提交回复
热议问题