Performing double-click on an element

There will be elements in a web application that need double-click events fired to perform some actions. For example, double-clicking on a row of a table will launch a new window. The Advanced User Interaction API provides a method to perform a double-click.

In this recipe, we will use the Actions class to perform double-click operations.

How to do it...

Let's create a test that locates an element for which a double-click event is implemented. When we double-click on this element, it changes its color:

package com.secookbook.examples.chapter04; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.By; import org.openqa.selenium.interactions.Actions; ...

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.