AutoFill forms in webview using javascript (Android)

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=" {&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 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.

+2
javascript android html webview
Jun 05 '16 at 17:04 on
source share

No one has answered this question yet.

See similar questions:

13
Fill in the fields in the web view automatically
9
Android WebView always returns null for javascript getElementById on loadUrl
5
Prefill WebView Text Fields
one
android get text from html hidden form field
0
How to fill in fields in web view in android using java and javascript

or similar:

7649
How do JavaScript locks work?
7494
How to remove a specific element from an array in JavaScript?
7432
How to check if a string contains a substring in JavaScript?
7287
What does use strict do in JavaScript, and what are the reasons for this?
5722
How to remove a property from a JavaScript object?
5670
Which operator is equal (== vs ===) should be used in comparing JavaScript?
5101
What is the most efficient way to deeply clone an object in JavaScript?
4829
How to include a javascript file in another javascript file?
4380
For each array in javascript?
3953
What href should be used for JavaScript, "#" or "javascript: void (0)" references?



All Articles