Question

I am new to Watir (and JavaScript as well) and have been following the related questions (and answers as well). I've also gone through the "Firebug" suggestion. I couldn't quite gather what we are supposed to do after finding out which events are fired.

In the following case, manually clicking on "Overview" suffices but I'm unable to write a code to automate the same.

<div id="overview" class="dijitTreeIsRoot dijitTreeNode dijitTreeNodeUNCHECKED dijitUNCHECKED" role="presentation" style="background-position: 0px 0px;" widgetid="dijit__TreeNode_10">

<div class="dijitTreeRow" data-dojo-attach-event="onmouseenter:_onMouseEnter, onmouseleave:_onMouseLeave, onclick:_onClick, ondblclick:_onDblClick" role="presentation" data-dojo-attach-point="rowNode" title="" style="padding-left: 0px;">

<img class="dijitTreeExpando dijitTreeExpandoLeaf" role="presentation" data-dojo-attach-point="expandoNode" alt="" src="/hcsadmin/open/dojo/resources/blank.gif">

<span class="dijitExpandoText" role="presentation" data-dojo-attach-point="expandoNodeText">*</span>

<span class="dijitTreeContent" role="presentation" data-dojo-attach-point="contentNode">

<img class="dijitIcon dijitTreeIcon dijitLeaf" role="presentation" data-dojo-attach-point="iconNode" alt="" src="/hcsadmin/open/dojo/resources/blank.gif">

<span class="dijitTreeLabel" data-dojo-attach-event="onfocus:_onLabelFocus" aria-selected="false" tabindex="-1" role="treeitem" data-dojo-attach-point="labelNode">Overview</span>

</span>

</div>

<div class="dijitTreeContainer" style="display: none;" role="presentation" data-dojo-attach-point="containerNode"></div>

</div>

Now I can flash the "Overview" using:

browser.div(:id, "overview").flash

and it does successfully flashes. But as suspected,

browser.div(:id, "overview").click

does NOT work.

Please provide a solution (or even better, a code) for this.

Was it helpful?

Solution

You're going to have to experiment a little bit, but orde already pointed to the approach to take that will probably work.

I suspect that something along these lines is probably the right answer:

browser.div(id: "overview").span(class: "dijitTreeLabel").fire_event "onfocus"

You may have to follow that line up with another one that does the click...

browser.div(id: "overview").span(class: "dijitTreeLabel").fire_event :click

...again, it's hard to know definitively what's going to work, so you'll have to experiment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top