Introduction
I want to automate a webpage loaded into webview in Android. I will load a webpage and then it will automatically fill the fields in the page and it will click the submit button and the next page will be displayed. The values that will be filled are defined by the user previously and saved into database. The webpage in not owned by me, so I cannot directly create a service from server side. I have to do everything from the client side.
Here is what I have done:
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 fill the id txtRegNo i have used this code in onPageFinished in webview :
String password = "1201329022";
webview.loadUrl("javascript:var uselessvar =document.getElementById('txtRegNo').value='" + password + "';");
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 fill the id dpStudentdob_dateInput:
String date= "5/8/2014";
webview.loadUrl("javascript:var uselessvar =document.getElementById('dpStudentdob_dateInput').value='" + date+ "';");
but the page says please enter correct date. but when the same date is entered by typing this is taken as right parameter and i get the result.
the original webpage to be operated is this.
And I want to fill the fields automatically and click the button with the help of java script.
how do I achieve this? Please do suggest any solution.