Find child element

3 posts, 1 answers
  1. Lachlan
    Lachlan avatar
    2 posts
    Member since:
    Apr 2012

    Posted 09 Oct 2012 Link to this post


    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>  

    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!


  2. Answer
    Byron avatar
    184 posts

    Posted 11 Oct 2012 Link to this post

    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,
    the Telerik team
    Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
    Vote now
  3. Lachlan
    Lachlan avatar
    2 posts
    Member since:
    Apr 2012

    Posted 11 Oct 2012 Link to this post

    That's perfect Byron, works like a charm!

Back to Top