How may I use Javascript Executor to enter data to a textbox field?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes

You can do that by changing value attribute of TextBox filed 

webdriver.executeScript("document.getElementById('elementID').setAttribute('value', 'your text here')");
But ideal option will be to use elem.sendKeys("your text here"); Where elem is identification of your text.

Hope it helps.