ACTION CLASSES

  

package mypackage;

 

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.remote.server.handler.SendKeys;

 

public class MouseActions {

 

public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver","C:\\Browser\\geckodriver.exe");

WebDriver driver=new FirefoxDriver();

driver.manage().window().maximize();

driver.get("https://opensource-demo.orangehrmlive.com/");

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

 

driver.findElement(By.id("txtUsername")).sendKeys("Admin");

driver.findElement(By.id("txtPassword")).sendKeys("admin123");

driver.findElement(By.id("btnLogin")).click();

 

Actions action=new Actions(driver);

action.moveToElement(driver.findElement(By.id("menu_admin_viewAdminModule"))).perform();

action.moveToElement(driver.findElement(By.id("menu_admin_Organization"))).perform();

action.moveToElement(driver.findElement(By.id("menu_admin_viewLocations"))).click().perform();

driver.findElement(By.id("searchLocation_name")).sendKeys("chittoor");

action.doubleClick(driver.findElement(By.id("searchLocation_name"))).perform();

 

driver.navigate().to("https://swisnl.github.io/jQuery-contextMenu/demo.html");

 

WebElement right=driver.findElement(By.xpath("//span[text()='right click me']"));

action.contextClick(right).perform();

action.sendKeys(Keys.ARROW_DOWN).perform();

action.sendKeys(Keys.ARROW_DOWN).perform();

System.out.println(driver.switchTo().alert().getText());

driver.switchTo().alert().accept();

}

}