Monday 16 February 2015

Mouse Hover in Selenium Webdriver

Mouse Hover In Selenium Webdriver : Go to the url: http://www.guru99.com/ and mouse hover on 'Testing' and click on 'Selenium' , below I'm adding the code kindly execute it.


package GuruMouseHover;

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

    public static void main (String[] args)
    {

        try{

            WebDriver driver = new FirefoxDriver();         
            driver.get("http://www.guru99.com");
            WebElement element = driver.findElement(By.linkText("Testing"));
            Thread.sleep(2000);
            Actions action = new Actions(driver);
            action.moveToElement(element).build().perform();

//Click on Selenium
            driver.findElement(By.xpath(".//*[@id='rt-header']/div/div[2]/div/ul/li[2]/div/div/ul/li[3]/a")).click();
      
        driver.close();
      
        }
        
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
  
  
}

No comments:

Post a Comment