Completing a login form programmatically:
document.getElementById('i0116').value = email;
document.getElementById('i0118').value = password;
document.getElementById('idSIButton9').click();
A challenge arises when the form recognizes that the values are not filled using key events. Even after filling the form, the placeholders remain and upon submission, an error stating that the fields are empty is displayed.
I attempted to solve this by triggering a keypress event on the input box before entering the value, but was unsuccessful. Here is what I tried:
var target = document.getElementById('email');
var evt = document.createEvent("Events");
evt.initEvent("keypress", true, true);
evt.view = window;
evt.altKey = false;
evt.ctrlKey = false;
evt.shiftKey = false;
evt.metaKey = false;
evt.keyCode = 0;
evt.charCode = 'a';
target.dispatchEvent(evt);
In addition, I tested using "UIEVENTS" and "KEYEVENTS", but none of them resolved the issue. I am using the Chrome browser.