2012-07-06 18 views
0

我試圖自動化一個GWT網絡應用程序和標準點擊按鈕不起作用。 因此,我正在模擬鼠標事件。發現 的代碼示例在線:Java WebDriver:如何獲取Coordinates類的實例?

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 

我怎樣才能獲得一個座標對象的有效實例?

回答

1

這是你怎麼做..

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