The click and hold a WebElement action

In the previous section, we have seen the clickAndHold() method, which will click and hold a WebElement at the current position of the cursor. It doesn't care about which element it is dealing with. So, if we want to deal with a particular WebElement on the web page, we have to first move the cursor to the appropriate position and then perform the clickAndHold() action. To avoid the hassle of moving the cursor geometrically, WebDriver provides the developers with another variant or overloaded method of the clickAndHold() method that takes the WebElement as input.

The API syntax is this:

public Actions clickAndHold(WebElement onElement)

The input parameter for this method is the WebElement that has to ...

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.