Right click on the mouse

package test;
import java.util.concurrent.TimeUnit;
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.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;

public class RightClick {

@Test
public void rightClicktest(){
WebDriver driver = new FirefoxDriver();
driver.navigate().to(http://www.google.com);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id(“lst-ib”)));

WebElement element = driver.findElement(By.id(“lst-ib”));
element.sendKeys(“”);
element.click();

Actions actObj = new Actions(driver);
actObj.contextClick(element).sendKeys(Keys.ARROW_DOWN).
sendKeys(Keys.ARROW_DOWN).
sendKeys(Keys.ARROW_DOWN).
sendKeys(Keys.ARROW_DOWN).
sendKeys(Keys.RETURN).perform();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s