Single Post

Header

Monday, February 8, 2016

Mouse Over and Click on Sub Menu link using Selenium WebDriver

Mouse Over and Click on Sub Menu link using Selenium WebDriver

import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class MouseOverAndClickSubMenu {


@Test
public void mouseOverAndClickSubMenu() throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://flex.apache.org/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
WebElement menu = driver.findElement(By.xpath(".//*[@id='nav']/li[2]/a"));
WebElement subMenu = driver.findElement(By.xpath(".//*[@id='nav']/li[2]/ul/li[5]/a"));
Actions act = new Actions(driver);
act.moveToElement(menu).perform();     // Mouse over an element
Thread.sleep(2000);
act.click(subMenu).perform();   // Click on a sub menu link
Thread.sleep(3000);
driver.quit();
}


}

3 comments:

  1. Automated Forex Trading : exness login Is An Automated Forex Investing Software. It Is An Algorithmic Trading Software That Provides Automated Forex Trading Signals.

    ReplyDelete
  2. Trade FX At Home On Your PC: exness login Is A Forex Trading Company. The Company States That You Can Make On Average 80 – 300 Pips Per Trade.exness login States That It Is Simple And Easy To Get Started.

    ReplyDelete