This is a migrated thread and some comments may be shown as answers.

Find child element

2 Answers 366 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lachlan
Top achievements
Rank 1
Lachlan asked on 09 Oct 2012, 06:02 AM
Hi,

This is a somewhat convoluted request, but I'll do my best to describe it!

I am trying to test a section of our app, and we are using the Rad Treeview control which has been slightly modified to incorporate some extra functionality. From what I can see, on the front end the treeview is built using a series of divs and spans, most of which use the same classes. I am trying to find particular nodes in the treeview but our modifications pass id's (which are randomly generated) to the particular nodes, so I cannot use these for finding elements.

A sample of code containing the elements I am trying to find is below. In particular I am trying to find the span with the id thisSpan_randomId. All of the specific attributes of this element are shared with other objects in the DOM.

<div class="rtBot">   
    <span class="rtSp"></span>  
    <span class="rtPlus"></span>  
    <img src="" longdesc="Region" alt="" class="rtImg">  
    <span class="rtIn">TS Test Region  
       <span class="tvContext" name="contextMenu" style="display:none;" id="thisSpan_randomId">  
          <a href='javascript:addRegionAccess("","747383be52bd4960b0b12331ed690c26", "TS%20Test%20Region");' innerhtml="Add Region Access" class="addRegion">Add Region Access</a>  
       </span>  
    </span>  
</div>

Using the Find Element dialog, I can locate the parent of the element I am trying to find using TextContent is exactly TS Test Region, but the child has no particular identifiers that I can use that are not already shared with other elements on the page.

Is there a way I can find this child element (with no unique identifiers) by first finding the parent (with unique identifiers)?

Hopefully this makes a bit of sense!

Cheers,

Lachlan

2 Answers, 1 is accepted

Sort by
0
Accepted
Byron
Telerik team
answered on 11 Oct 2012, 10:21 PM
Hello Lachlan,

I just published a new user guide article to describe a solution to this problem: chained find expressions. Please let me know if this helps resolve your issue.

Kind regards,
Byron
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
Lachlan
Top achievements
Rank 1
answered on 11 Oct 2012, 10:28 PM
That's perfect Byron, works like a charm!

Thanks!
Tags
General Discussions
Asked by
Lachlan
Top achievements
Rank 1
Answers by
Byron
Telerik team
Lachlan
Top achievements
Rank 1
Share this question
or