简体   繁体   中英

Java WebDriver: How can I obtain an instance of a Coordinates class?

I am trying to automate a GWT web app and standard clicks on a button don't work. Therefore, I am simulating mouse events instead. The code examples found online:

Mouse mouse = ((HasInputDevices)driver).getMouse();
mouse.mouseDown((Coordinates)myButton.getLocation());
mouse.mouseUp((Coordinates)myButton.getLocation());

But then I get:

Exception in thread "main" java.lang.ClassCastException: Point cannot be cast to Coordinates

How can I obtain a valid instance of a Coordinates object?

This is how you do it..

Locatable button = (Locatable) myButton;
Mouse mouse = ((HasInputDevices)driver).getMouse();
mouse.mouseDown(button.getCoordinates());
mouse.mouseUp(button.getCoordinates());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM