How to right click on a link and select an option using Selenium WebDriver ?

package TechLearndotin; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

 

public class Rightclick {
      public WebDriver driver;
    
  @Test //Right Click a Link,Button and Image etc.. using Selenium Webdriver
       public void RightClick() throws Exception {
       driver.get("http://www.techlearn.in/");
       Thread.sleep(3000); 
       Actions act=new Actions(driver);
       act.contextClick(driver.findElement(By.linkText("Quiz"))).perform();

       }
  @BeforeTest
      public void beforeTest() {
      driver = new FirefoxDriver();
      driver.manage().window().maximize();
      }

  @AfterTest
     public void afterTest() {
       }
       }

Tags: 

Comments