I am using webview_flutter.
I currently have a native login page in my app that takes in a user's name and password. I am trying to find a way to automatically fill in the username and password on the specific page in webview and submit the login request.
Tried doing this
webViewController.evaluateJavascript(
'''
var email = document.getElementById("CustomerEmail");
var password = document.getElementById("CustomerPassword");
email.value = "user@gmail.com";
password.value = "test123";
'''
);
but got the following errors:
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=3, WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 'email.value = "user@gmail.com"'), WKJavaScriptExceptionColumnNumber=11, WKJavaScriptExceptionSourceURL=undefined, NSLocalizedDescription=A JavaScript exception occurred})
Greatly appreciate any help on this. Thank you.