Automating textboxes, text areas, and buttons

The textbox and button elements are the most common elements used in any web application. Selenium WebDriver's WebElement interface provides methods to simulate keyboard entry into textboxes or text areas and perform clicks on a button control.

In this recipe, we will explore these methods to automate textbox, text-area, and button elements.

How to do it...

Here we will explore the clear(), sendKeys(), submit() and click() methods of the WebElement interface.

Clearing text from textbox and text-area elements

To clear the existing text value from textbox and text-area elements, we can use the clear() method, as shown in following code example:

// Find the text input element by its name WebElement element ...

Get Selenium Testing Tools Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.