The click on a WebElement action

We have seen how to click a WebElement by calculating the offset to it. This process may not be needed every time, especially when the WebElement has its own identifiers, such as a name or an ID. We can use another overloaded version of the click() method to click directly on the WebElement.

The API syntax for clicking on a WebElement is as follows:

public Actions click(WebElement onElement)

The input parameter for this method is an instance of the WebElement on which the click action should be performed. This method, like all the other methods in the Actions class, will return an Actions instance.

Now let's try to modify the previous code example to use the click(WebElement) method, instead of using the ...

Get Selenium WebDriver 3 Practical Guide - 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.