Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How can you send text input to a focused element?

Category: Selenium WebDriver

This can be done by simulating key presses on the focused element. One way is to perform “actions” on the web driver object:

new Actions(webDriver).sendKeys(“some text”).perform();

An alternative way is to switch to the active element first, and send keys to it directly:

webDriver.switchTo().activeElement().sendKeys(“some text”);

Leave a Reply

Your email address will not be published. Required fields are marked *