Saturday, September 14, 2019

Post#62.DoubleClick in Selenium


Double Click in Selenium
We can double click an element or an webpage using Actions class in selenium, doubleClick() method in Actions class helps us to do a double click on the elements.
Consider you want to perform Double Click action on any web element i.e. as per given in below screenshot.


After Double Click on the Above Web Element below pop up will give you confirmation about double click action.

Script:
package pack2;
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.Action;
import org.openqa.selenium.interactions.Actions;

public class DoubleClick {

  public static void main(String[] args) {
   
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("http://www.testingbar.com/doubleclick/");
    WebElement dElement = driver.findElement(By.xpath("//*[@id='post-746']/div/p[1]/button"));
    Actions a = new Actions(driver);
    a.doubleClick(dElement).perform();
    driver.close();
}
}


6 comments: