The moveToElement() method is another method of WebDriver that helps us to move the mouse cursor to a WebElement on the web page.
The API syntax for the moveToElement() method is as follows:
public Actions moveToElement(WebElement toElement)
The input parameter for the preceding method is the target WebElement, where the mouse should be moved. Now go back to the clickAndHold at current location action section of this chapter and try to modify the code to use this method. The following is the code we have written in The click-and-hold-at-current-location action section:
@Testpublic void shouldClickAndHold() { driver.get("http://guidebook.seleniumacademy.com/Sortable.html"); Actions actions = new Actions(driver);