Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukestanley/0afdcbed056de5ab7003e8586e60def3 to your computer and use it in GitHub Desktop.
Save lukestanley/0afdcbed056de5ab7003e8586e60def3 to your computer and use it in GitHub Desktop.
Updating text box values on DOM elements in React using dispatchEvent - login example
function simulate_input_event(element) {
var event = new Event('input', { bubbles: true });
element.dispatchEvent(event);
}
document.forms[0][0].value='username';
simulate_input_event(document.forms[0][0]);
document.forms[0][1].value='password';
simulate_input_event(document.forms[0][1]);
document.forms[0][2].click() //click the login button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment