Java / Android: simulate click on submit button (HTML)

624 views Asked by At

I want to simulate a click on a website on a submit-type button

this is the code for now, but apparently it does not work:

                                 String id = "x";
                                 String pw = "y";

                                 web.getSettings().setDomStorageEnabled(true);

                                 web.loadUrl("javascript: {" +
                                         "document.getElementsByName('authid')[0].value = '"+id +"';" +
                                         "document.getElementsByName('authpw')[0].value = '"+pw +"';" +
                                         "var submit = document.getElementsByClassName('inputbutton');" +
                                         "submit[0].submit(); };");

and this is how it looks like: Screenshot of Emulator

the code for the button on the website:

<input type="submit" value="OK" class="inputbutton">

thanks in advance :)

1

There are 1 answers

0
quidproquo On BEST ANSWER

thanks for the vote up, I've got the answer:

instead of submit[0].submit(); in the last line of the first code part it has to be submit[0].click();