I am trying to trigger a mouse over drop down window in Watir on ruby.
I have tried it using both of the two scripts below, so far neither have worked.:
$browser.div(:class => "rolloverMAINMenu").fire_event("onMouseOver")
and
$browser.a(:style=>"background-color:cccccc;width:200px;").fire_event("onMouseOver")
HTML:
<font COLOR="green">
<a style="background-color:cccccc;width:200px;" onmouseover="rolloverMenu(1, 'mainMenu');" onmouseout="rolloverMenu(0, 'mainMenu');"
onclick="rolloverMenu(0, 'mainMenu');">
<B> Roll Over Menu </B></a>
<div style="background-color:cccccc;width:200px;" class="rolloverMAINMenu" id="mainMenu" style="display: none;" onmouseover="rolloverMenu(1, 'mainMenu');"`
For the div, since it has an ID, I’d recommend using that to identify it since ID values should (according to the HTML spec) should be unique on the page. That will insure you are selecting the correct element.
Secondly since the code is looking for ‘onmouseover’ I would specify the event that way and not use camelCase
For the link, the problem you are having is identifying it. I do not see :style listed as an option for identifying elements (although potentially that doc could be out of date) I might suggest using the text or some other aspect, or you may need to resort to xpath.
Or since the link is set to react to click, you could try that also
If you are placing these in a script, since the client is executing javascript methods in response to the events, you may need to have a small pause in the script at that point to allow for the DOM to be updated, before you try to interact with any elements rendered to the screen in response to the mouseover or click