package softwaretesting-guru;
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 RightClick {
public static void main(String[] args)
{
//Launch the
browser
WebDriver
driver=new FirefoxDriver();
//Enter URL
driver.get("http://www.gmail.com");
//Enter the data in
gmail username
driver.findElement(By.id("Email")).sendKeys("Selenium");
//rightclick
on gmail username field
//WebElement
represents any HTML element.
WebElement
elementRC = driver.findElement(By.id("Email"));
//Use this class
rather than using the Keyboard or Mouse directly.
Actions builder = new Actions(driver);
// Performs a
context-click at the current mouse location
Action rClick =
builder.contextClick(elementRC).build();
//A convenience method for performing the
actions without calling build() first.
rClick.perform();
}
}