-2

I have a requirement that when a certain automation script is run, the browser should show the cursor moving from one field to another as the script moves ahead. I am not sure about what exactly I need to do to get it done. I used the Action class to implement it but it's not working.

Please find the code I have implemented below:

public void MouseHover(WebElement Mouse,WebDriver driver) throws InterruptedException
{
    Actions act = new Actions(driver);  
    act.moveToElement(Mouse).build().perform();
    System.out.println("Curser movement Performed Successfully");
}
Joel Anair
  • 13,832
  • 3
  • 31
  • 36
user3300977
  • 1
  • 1
  • 2

1 Answers1

4

The java.awt.Robot class can be used to programmatically move the user's mouse (among other things). See: Link.

For example:
Robot r = new Robot();//construct a Robot object for default screen r.mouseMove(1360, 7);//move mouse to java coords 1360, 7 r.mousePress(InputEvent.BUTTON1_MASK);//press the left mouse button r.mouseRelease(InputEvent.BUTTON1_MASK);//release the mouse button

Treker
  • 386
  • 2
  • 9
  • Thank you For Response. I og through the link but not able to understand it. I am very new to this stuff, If you have any related code then could you please paste it here...and it will really help me if you also paste steps about how to do it... – user3300977 Jul 10 '14 at 13:41