5

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="        {&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;&quot;,&quot;valueAsString&quot;:&quot;&quot;,&quot;minDateStr&quot;:&quot;01/01/1960&quot;,&quot;maxDateStr&quot;:&quot;01/01/2015&quot;}">
</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.

2
  • have got any solution regarding this? Commented Nov 29, 2017 at 14:37
  • I also want to implement this functionality Commented Nov 29, 2017 at 14:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.