I want to autofill for example Facebook's login fields(email and password) or Google's search field. I have gone through many questions about autofill, including this.
This is my code at the moment, which opens up the website in the WebView, but doesn't fill out anything. And for the getElementById I inspected the facebook's email and password fields and their ID's were email and pass.
webView = (WebView) findViewById(R.id.webView1);
webView.loadUrl("https://www.facebook.com");
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
String user = "udb";
String pwd = "abcdefg";
view.loadUrl("javascript:document.getElementById('email').value = '" + user + "';document.getElementById('pass').value='" + pwd + "';");
System.out.println("AUTOFILL");
}
});
and it gives me this error
I/chromium: [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot set property 'value' of null", source: (1)
I don't know much about javaScript though.