Styrow.dev
Question 39 of 82

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’"");


📲 Practice Offline on Mobile: Download the free QA Automation & SDET Prep app on Google Play & App Store.