Wednesday, 5 August 2015

Work with mouse right click operations

package gooGle;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

public class Right_Click {
  @Test
public void TestClick() throws Exception{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.google.com");
driver.manage().window().maximize();
Actions act=new Actions(driver);
act.contextClick(driver.findElement(By.xpath("//*[@id='lga']"))).perform();  //  ////*[@id='addlang']/a[6]
}
@Test
public void rightClickAndSelectOption()
{
      WebDriver driver1=new FirefoxDriver();
      driver1.navigate().to("http://www.google.com");
     
      driver1.manage().window().maximize();
     
      WebElement oWE=driver1.findElement(By.linkText("About"));
     
      Actions oAction=new Actions(driver1);
      oAction.moveToElement(oWE);
      oAction.contextClick(oWE).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
}
}


No comments:

Post a Comment