O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing an extension for the WebElement object to set the element attribute values

Setting an element's attribute can be useful in various situations where the test needs to manipulate properties of an element. For example, for a masked textbox, the sendKeys() method may not work well, and setting the value of the textbox will help to overcome these issues. The WebElement object does not have a method that supports setting all types of attributes.

In this recipe, we will create an extension for WebElement and provide a method to set the attribute value of an element at runtime.

Getting ready

Create a new Java class file for the WebElementExtender.java class. We will use this class to host all the extension methods for the WebElement objects. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required