Tuesday, May 24, 2016

Perform mouseover function in Selenium WebDriver using Java

import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Test1
{

    public static void main(String[] args) throws InterruptedException
    {
       
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("http://flex.apache.org/");
        Actions action = new Actions(driver);
        action.moveToElement(driver.findElement(By.xpath(".//*[@id='nav']/li[2]/a"))).build().perform();
        Thread.sleep(1000);
        action.click(driver.findElement(By.xpath(".//*[@id='nav']/li[2]/ul/li[2]/a"))).perform();

     }
}

No comments :

Post a Comment