Friday, 19 July 2013

Selenium WebDriver : Implementing Hover Using Mouse

Code for hover using mouse is as follows -
public static void mouseOverOnElement(WebElement tagElement)
{
  try
     {
                System.out.println(”mouseOverOnElement Starts ->”);
                Actions builder=new Actions(driver);
                Point coordinate=tagElement.getLocation();
                Robot robot=new Robot();
                builder.moveToElement(tagElement, 5,5).build().perform();
                builder.moveByOffset(1, 1).build().perform();
                robot.mouseMove(coordinate.getX()+15,coordinate.getY()+104);
                Thread.sleep(3000);
                System.out.println(”mouseOverOnElement Ends ->”);
      }
     catch(Exception e) { }
}

No comments:

Post a Comment