Last active
August 19, 2021 23:45
-
-
Save yeisoncruz16/5c8197664070f8c3f4b4dad3f338e761 to your computer and use it in GitHub Desktop.
How to update html field value when the page is using React
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
sendKeys(document.getElementById("SELECTOR_GO_HERE"), "My cool message to type", 'input'); |
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
const sendKeys = (targetObject, value, eventType) => { | |
targetObject.value = value; | |
let event = new Event(eventType, {target: targetObject, bubbles: true}); | |
targetObject.dispatchEvent(event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment