Event Firing Mouse - Selenium
Here I am going to explain how to move the mouse using the
Event Firing Mouse. One need to keep in mind that this does not move the mouse
physically.
You can check the Mouse interface on Seleniumhq.org for more
details .
Below are the methods which can be used with Mouse Interface
Important steps in
this:
- Identify the object(Using Xpath in this case)
- Get the Coordinates
- Move the Mouse.
public static void main (String args[])
throws
InterruptedException{
//KeyPress();
WebDriver
webdriver = new FirefoxDriver();
EventFiringWebDriver
driver = new EventFiringWebDriver(webdriver);
weblisteners
listener = new weblisteners();
EventFiringMouse
mouse = new EventFiringMouse(webdriver, listener);
driver.navigate().to("http://google.com");
Thread.sleep(3000L);
//Move the Mouse
over Business in Footer of Google.com
Locatable
hoverItem = (Locatable) driver.findElement(By.xpath("//*[@id='fsl']/a[2]"));
Coordinates
cord = hoverItem.getCoordinates(); // Get the Coordinates of Item
try{
mouse.mouseMove(cord);
//
Move the Mouse.
}catch(Throwable t){
}
}
No comments:
Post a Comment