Mouse hover action in selenium Webdriver


package selenium_examples;

import java.util.concurrent.TimeUnit;

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 spicejet {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();
driver.get("http://spicejet.com/");

Actions builder = new Actions(driver);
WebElement Element = driver.findElement(By.xpath("html/body/div[2]/div[1]/div/div[2]/div[2]/div/ul/li[4]/a"));
builder.moveToElement(Element).build().perform();

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

driver.findElement(By.xpath("/html/body/div[2]/div/div/div[2]/div[2]/div/ul/li[4]/ul/li/a")).click();

System.out.println("Done!");

}
}

Above script opens http://spicejet.com/ website and hovers over menu item "Travel Tips" and clicks "FAQ's".

selenium scripts




No comments:

Related Posts Plugin for WordPress, Blogger...