So specifying the entire path to get to an element tends to create brittle 
code, one error in the 'chain' or one change to the page and you are sunk

secondly, in general it is best to use the method for the element type you 
want, this ensures that proper methods will be present in the returned 
object, e.g. set methods on a text field, etc

ID values, by HTML standards should be unique, so in a case like that there 
is no reason to specify the other container elements that enclose the thing 
you want.  You really only want to do that if you need to be sure that the 
one element is inside another, or it would be ambiguous otherwise as more 
than one element with a given set of properties exists.

So combining all that, you ought to be able to do a much more direct access 
of your element by using

browser.td(:id => 'dijit_MenuItem_16_text').exists?

If that comes back negative, then I would look to see if there is a frame 
and the elements are inside the frame.  Since each frame acts like it's own 
browser window with it's own DOM, you MUST specify frames when elements are 
inside them, aside from typos or using wrong identifiers for an element, 
that is the most common cause of exists? returning false

On Thursday, May 14, 2015 at 10:07:21 AM UTC-7, Jing Xie wrote:
>
> I am trying to select an element from a table of dropdown menu and found 
> that I am not able to locate that.
>
> @browser.div(:id, 'wikiActionMenuLink_dropdown').element(:tag_name, 
> 'table').element(:tag_name, 'tbody').element(:tag_name => 'td', :id => 
> 'dijit_MenuItem_16_text').exists?
> The output is false. Below is the html. Could someone give me some 
> suggestions?
>
>
> <table id="dijit_Menu_2" class="dijit dijitReset dijitMenuTable 
> lotusPlain dijitMenu dijitMenuPassive" cellspacing="0" tabindex="0" role="
> menu" widgetid="dijit_Menu_2" style="top: 0px; visibility: visible;">
> <tbody class="dijitReset" data-dojo-attach-point="containerNode">
> <tr id="dijit_MenuItem_15" class="dijitReset dijitMenuItem" tabindex="-1" 
> role="menuitem" data-dojo-attach-point="focusNode" style="-moz-user-select: 
> none;" aria-label="Edit Wiki " title="Edit settings of this wiki." 
> widgetid="dijit_MenuItem_15">
> <td class="dijitReset dijitMenuItemIconCell" role="presentation">
> <td id="dijit_MenuItem_15_text" class="dijitReset dijitMenuItemLabel" role
> ="presentation" data-dojo-attach-point="containerNode,textDirNode" colspan
> ="2">Edit Wiki</td>
> <td id="dijit_MenuItem_15_accel" class="dijitReset dijitMenuItemAccelKey" 
> data-dojo-attach-point="accelKeyNode" style="display: none"></td>
> <td class="dijitReset dijitMenuArrowCell" role="presentation">
> </tr>
> <tr id="dijit_MenuItem_16" class="dijitReset dijitMenuItem" tabindex="-1" 
> role="menuitem" data-dojo-attach-point="focusNode" style="-moz-user-select: 
> none;" aria-label="Delete Wiki " title="Delete this wiki." widgetid="
> dijit_MenuItem_16">
> <td class="dijitReset dijitMenuItemIconCell" role="presentation">
> <td id="dijit_MenuItem_16_text" class="dijitReset dijitMenuItemLabel" role
> ="presentation" data-dojo-attach-point="containerNode,textDirNode" colspan
> ="2">Delete Wiki</td>
> <td id="dijit_MenuItem_16_accel" class="dijitReset dijitMenuItemAccelKey" 
> data-dojo-attach-point="accelKeyNode" style="display: none"></td>
> <td class="dijitReset dijitMenuArrowCell" role="presentation">
> </tr>
> </tbody>
> </table>
>

-- 
-- 
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/d/optout.

Reply via email to