We ran into some issues and I thought I would share how we resolved them.
Issue #1 - We have a CSS hover based hierarchical menu in our web app. It
has an always visible top level and two sub-levels that only appear as you
hover and navigate through the menu. We could get the first sub menu
(top-sub) to appear using element.hover but when we tried to get the second
level sub menu (top-sub-sub) it would flash and then both sub levels would
disappear again. As best as I could determine there is a bug in either
web-driver or IE that when the second level sub menu got element.hover the
first sub menu lost its hover. Normally when you hover with a mouse the
parent retains the hover but that wasn't happening here.
Issue #2 - We have menu items created using jQuery with jQuery based click
events. These were not being performed using fire_event('onClick'). No
error, the event simply didn't fire.
In the end we resorted to javascript for all menu navigation and clicking.
It works great and has the added advantage of being much faster (no need
for the painfully slow element.when_present calls). Additionally we
previously experienced intermittent flakiness navigating the menus, that is
no longer an issue.
Unlike with Watir when using Javascript displaying the menu items isn't
required. We decided to display them anyway so that when the script is
being watched by someone they can tell what it is doing. With Javascript
you can't simulate a CSS hover, therefore we simply set visibility to
visible (which is what the CSS does). The jQuery based Javascript call
from Watir to show a submenu is:
jquerySelector = '#MYELEMENTID'
script = <<-js
$(arguments[0]).css('visibility', 'visible');
js
$b.execute_script(script, jquerySelector)
The Watir and Javascript (with jQuery) code for clicking the menu item is:
jquerySelector = '#MYELEMENTID'
script = <<-js
$(arguments[0]).click();
js
$b.execute_script(script, jquerySelector)
We only test with IE (that is all our customers use) so I don't know if
these are IE specific issues or not.
Hopefully someone else will be spared the huge amount of time we invested
before getting to this solution.
-Mont
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.