Styrow.dev
Question 39 of 64

Can we pass a text to textbox without using sendKeys()? If Yes, Explain how it can be done?

Question

Can we pass a text to textbox without using sendKeys()? If Yes, Explain how it can be done?

Answer

It can be done with JavaScriptExecutor. Below steps can be performed

// To initialize js object

JavascriptExecutor JS = (JavascriptExecutor)webdriver;

// To enter username

JS.executeScript(""document.getElementById(‘User’).value=‘CodeGreen_user1’"");