Sceanrio:
- Launch the browser
- Navigate to google.com
- right click on google page
- Click on View page source
public class rightClick {
WebDriver driver;
@Test
public void f() {
WebElement searchButton= driver.findElement(By.name("btnK"));
Actions action=new Actions(driver);
action.contextClick(searchButton).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).perform();
//action.contextClick(searchButton).build().perform();
//action.contextClick(viewPort).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).perform();
}
@BeforeTest
public void beforeTest() {
driver=new FirefoxDriver();
driver.get("http://google.co.in");
driver.manage().window().maximize();
}
@AfterTest
public void afterTest() {
driver.close();
}
}
No comments:
Post a Comment