How To Right Click on Element in Selenium Web Driver


Right Click in Selenium WebDriver

ContextClick()
By using Context Click Method We Right Click In selenium 

Syntax-



WebElement Rclick =driver.findElement(By.name("email"));
Actions act = new Actions(driver);
act.contextClick(Rclick).perform();


Selenium Code For Right Click 



package automationtesting;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.interactions.Actions;

public class Rightclick {
       public static void main(String[] args) {
              System.setProperty("webdriver.chrome.driver","D:\\Sandeep\\Soft\\chromedriver.exe");
              WebDriver drivernew ChromeDriver();
              driver.manage().window().maximize();
              driver.get("https://www.facebook.com/");
              WebElement Rclick =driver.findElement(By.name("email"));
              Actions act = new Actions(driver);
              act.contextClick(Rclick).perform();
             
             
       }

}

Post a Comment

0 Comments