JavaWebDriver:如何获取坐标类的实例?

JavaWebDriver:如何获取坐标类的实例?,java,mouse,webdriver,coordinates,selenium-webdriver,Java,Mouse,Webdriver,Coordinates,Selenium Webdriver,我正在尝试自动化一个GWT web应用程序,但标准的按钮点击不起作用。 因此,我改为模拟鼠标事件。 可在网上找到代码示例: Mouse mouse = ((HasInputDevices)driver).getMouse(); mouse.mouseDown((Coordinates)myButton.getLocation()); mouse.mouseUp((Coordinates)myButton.getLocation()); 但我得到: Exception in thread "ma

我正在尝试自动化一个GWT web应用程序,但标准的按钮点击不起作用。 因此,我改为模拟鼠标事件。 可在网上找到代码示例:

Mouse mouse = ((HasInputDevices)driver).getMouse();
mouse.mouseDown((Coordinates)myButton.getLocation());
mouse.mouseUp((Coordinates)myButton.getLocation());
但我得到:

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

如何获取坐标对象的有效实例?

这就是您的方法

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