Introduction
I want to automate a webpage loaded in a webview on an Android device. I will load a web page and then it will automatically fill in the fields on the page and it will click the submit button and the next page will be displayed. the values ββto be filled are determined by the user earlier and stored in the database. the webpage does not belong to me, so I cannot directly create the service from the server side. I have to do everything from the client side.
Here is what I did:
HTML code:
<td> <input name="txtRegNo" type="text" id="txtRegNo" placeholder="Enter Registration No" style="height:24px;width:300px;" /> <span id="RequiredFieldValidator1" style="color:Red;visibility:hidden;">Enter Valid registration No.</span> </td>
To populate the txtRegNo , I used this code in onPageFinished in webview:
String password = "1201329022"; webview.loadUrl("javascript:var uselessvar =document.getElementById('txtRegNo').value='" + password + "';");
The problem I am facing:
HTML code:
<td class="rcInputCell" style="width:100%;"> <span id="dpStudentdob_dateInput_wrapper" class="riSingle RadInputRadInput_Default" style="display:block;width:100%;"> <input id="dpStudentdob_dateInput" name="dpStudentdob$dateInput" class="riTextBox riEnabled" type="text"> <input id="dpStudentdob_dateInput_ClientState" name="dpStudentdob_dateInput_ClientState" type="hidden" autocomplete="off" value=" {"enabled":true,"emptyMessage":"","validationText":"","valueAsString":"","minDateStr":"01/01/1960","maxDateStr":"01/01/2015"}"> </span> </td>
To populate the dpStudentdob_dateInput identifier:
String date= "5/8/2014"; webview.loadUrl("javascript:var uselessvar =document.getElementById('dpStudentdob_dateInput').value='" + date+ "';");
but the page says please enter a valid date. but when the same date is entered, typing this, it will be considered the correct parameter, and I get the result.
The source webpage to be used is this .
and I want to fill in the fields automatically and click a button using java script.
how can i achieve this please offer any solution.
javascript android html webview
Sagar Nayak Jun 05 '16 at 17:04 on 2016-06-05 17:04
source share