Reputation: 327
How do you simulate a mousemove event in watir?
I have a mildly fancy object that cares about the exact position of the mouse within that object.
Upvotes: 2
Views: 3851
Reputation: 2024
If firing the javascript mouseover event isn't specific enough...
browser.div(:id, "some-id").fire_event "onmouseover"
source: Mouse movement / mouseover and JavaScript evaluation in watir
...then you can try pairing Watir and autoit as described here to put the cursor in a specific location: http://www.autoitscript.com/autoit3/docs/functions/MouseMove.htm
browser.autoit.MouseMove(x,y)
If using Windows, Win32ole will also make use of autoit. There's a lot of this action documented in the 'how to handle pop-ups' section of the Watir FAQ. http://wiki.openqa.org/display/WTR/Pop+Ups
require 'win32ole'
a=WIN32OLE.new("AutoItX3.Control")
a.mousemove 100,100
a.mousemove 300,300
a.mouseclick "right"
Upvotes: 3