Created
July 26, 2017 15:41
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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