How to perform actions on an element by finding its parent element

2 posts, 0 answers
  1. Sudarshan
    Sudarshan avatar
    22 posts
    Member since:
    Feb 2013

    Posted 27 Apr 2013 Link to this post

    <div class="jsdomenuitem"................................ //parent
       Text - Aggregations
       <div class = "jsdomenuarrow" id = "menuitem209arrow"  //child


    I'm able to find the parent using Innertext property, by getting this i want to click the child. Child doesnt contain any innertext 
    I'm able to find the child by using id=menuitem209arrow but there are many cases like this, so instead of finding the child directly, i want to find Parent  and they perform actions on child.

    How to get the child by finding the parent?

  2. Boyan Boev
    Boyan Boev avatar
    1072 posts

    Posted 29 Apr 2013 Link to this post

    Hi Sudarshan,

    You can use the ChildNodes collection which contains all children of a parent element.

    I created a simple application to demonstrate it:


    <!DOCTYPE html>
    <div class="jsdomenuitem">
        <div id="menuitem209arrow">


    HtmlDiv parrent = ActiveBrowser.Find.ByContent<HtmlDiv>("Aggregations");
    Element child = parrent.ChildNodes[1];
    HtmlDiv ch = child.As<HtmlDiv>();

    I recorded a short video as a demonstration.

    Hope this helps.

    Kind regards,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top