December 1, 2021

Selenium Interview Questions on Textbox Part -1

Selenium Interview Questions on Textbox

1. How to type into a text box using selenium webdriver?

We have different ways to type text into textbox/textfield or text area

1. Using sendkeys - driver.findElement(locator).sendKeys("text");
2. Using JavascriptExecutor document.getElementById
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("document.getElementById('id').setAttribute('value','text')");
3. Using JavascriptExecutor arguments[0].value
jse.executeScript("arguments[0].value='enter the value here';", WebElement);



1 comment: