我正在尝试自动化 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());
关于Java网络驱动程序: How can I obtain an instance of a Coordinates class?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11366318/