0

In my application, I am showing our own e-commerce website in WebView. In that, I have username and password textboxes. I want to get username of text data while he is entering and want to store it in my file. I do not have any control of website(Login page). It is completely build by third party How can I achieve this ? please help. Thank you in advance.

1 Answers1

0

You can use JavaScript for load data from the webView. I use following JS code for load html from the webView JS_PARSER = "(function() { return ('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>'); })();" webview.getSettings().setJavaScriptEnabled(true); webView.evaluateJavascript(JS_PARSER, <callback for handle response with html>); evaluateJavascript docs

And try to load data from the html.

As second way you can make JS function for load text from the textBoxs. And execute the function for each textBox.

JS function for load data from textBox: function myFunction(){ return document.getElementById("f6").value; }

Android code for second way: String LOAD_FUN = function getValue(){ return document.getElementById('%s').value; }(); webView.evaluateJavascript(String.format(LOAD_FUN, "<String with textBoxId>"), <callback for handle textBox value>)

Vova
  • 956
  • 8
  • 22
  • Thank you for answer. But my problem is i do not have any control of website(Login page). It is completely build by third party. – Jithesh kumar Nov 28 '17 at 10:59
  • Try to execute, first way of my answer, and attach html response to the post, I try to help you. – Vova Nov 28 '17 at 11:05