Hi companions! in this post, we will figure out how to double tap a component utilizing Selenium Webdriver with Java. For double tapping a component in Selenium we utilize the Actions class. The Actions class gave by Selenium Webdriver is utilized to create complex client signals including right snap, double tap, intuitive and so forth.
Code scrap to double tap a component
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.id("elementId"));
action.doubleClick(element).perform();
Here, we are starting up an object of Actions class. From that point forward, we pass the WebElement to be double tapped as parameter to the doubleClick() technique present in the Actions class. At that point, we call the perform() technique to play out the created activity.
Test code to double tap a component
For the show of the double tap activity, we will dispatch Sample Site for Selenium Learning. At that point we will double tap the catch on which the content "Double tap to create ready box" is composed. After that an alet box will show up, affirming that double tap activity is effectively performed.
package seleniumTutorials;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class DoubleClick {
public static void main(String[] args) throws InterruptedException{
WebDriver driver = new FirefoxDriver();
//Launching sample website
driver.get("https://artoftesting.com/sampleSiteForSelenium");
driver.manage().window().maximize();
//Double click the button to launch an alertbox
Actions action = new Actions(driver);
WebElement btn = driver.findElement(By.id("dblClkBtn"));
action.doubleClick(btn).perform();
//Thread.sleep just for user to notice the event
Thread.sleep(3000);
//Closing the driver instance
driver.quit();
}
}