Reputation: 1
The code below does not work:
browser.link(:id => "tab_buy").fire_event ("onmouseover")
Whereas this code works well:
browser.link(:id => "tab_buy").click
works well.
This is true with both IE and Firefox. Please let me know if there are any workarounds.
Upvotes: 0
Views: 4926
Reputation: 6660
Keep in mind that the action of clicking on something has the potential to fire many different events including
This question and the answers might be of use: How to find out which JavaScript events fired? as a way to get an idea what events are firing off as you do some process like move the mouse over some object and click on it.
If your objective is to click the link, then using .click is usually the most direct and simple method to accomplish that. If on the other hand you have Javascript or CSS based actions taking place (common with robust custom controls, emulating dropdown menus, etc) then you may need to be firing events in order to have things happen such as a menu appearing when the mouse moves over the top item in a pulldown menu. (that can also be tricky since the way CSS reacts to 'psuedoclasses' defined with the 'hover' action is different from how event based javascript works.
To really give you more than basic info however, and provide a specific answer, you're going to have to share a lot more about what's going on, what you are trying to make happen, what is happening, etc since right now it would take a lot of mind reading for any of us to understand what your challenge is, and how you are currently attempting to overcome it.
Upvotes: 1
Reputation: 739
The last time I checked .fire_event("onmouseover") had not been implemented (watir-webdriver) in at least Firefox (this was a few months ago now).
The way I currently get around this is by using the following:
In a file included in all my tests:
class Watir::Element
def hover
assert_exists
driver.action.move_to(@element).perform
end
end
This gives each element a hover method, which is used like:
browser.div(:id => "someId").hover
And that's how I've been handling hover events so far. This was suggested (provided) by Jari Bakken when I ran into a similar problem with .fire_event("onmouseover")
during a test.
I'm not sure whether this will work in IE, as we're only using Firefox here.
Upvotes: 1