26
Jun

working with menus in Selenium (mouseover and click on link)

package SeleniumPractice;

import java.text.ParseException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

public class Workingwithmenus {
WebDriver driver;

@Test
public void enterText() throws InterruptedException, ParseException {

// First step set the driver location
System.setProperty(“webdriver.chrome.driver”, “C:\\softwares\\Selenium jars\\chromedriver.exe”);

// create chrome object
driver = new ChromeDriver();
// Navigate to site
driver.get(“https://www.actitime.com/download”);
WebElement features = driver.findElement(By.xpath(“/html/body/header/div/nav/ul/li[2]/a”));

// Create Object of Action Class
Actions action = new Actions(driver);

// Move to element for which you want mouse Over
action.moveToElement(features).build().perform();

// Just sleep for 1 second to make sure mouse over is successful.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Click on link
driver.findElement(By.linkText(“Work Scope Management”)).click();

driver.quit();
}
}