Forum Discussion

Vallalarasu_P's avatar
Vallalarasu_P
Frequent Contributor
10 years ago

Difference Between FindAll, FindChild, FindAllChildren ?

What is the best to use on which kind of scenarios?? Please explain with Example..



  • Let us take an Example:


    1. There is a webpage opened in a browser. There are 4 buttons "Ok", "Cancel", "Hide" & "Sort" button on this page. Attachd is the screenshot.


    2. In this page we have a webtable of 1 row and 4 columns in this page


    3. The header of this table is also webtable with 2 buttons each say "Name" "Sort", "Age" "Sort", "Company" "Sort", "Salary" "Sort"


    4. The 1st row 4th column there is another button named "Hide"


     


    Say the parent is objParent like below and let us see the results - 


    var objParent = Browser("brow").Page("pge");


     


    Find ("Sort" button)


    -------------------------------------------------------


    This methods finds/searches for required object(only 1 desired object) under the mentioned Parent and and as well as its children objects. The search is started from  objParent and continues down the object hierarchy to the specified depth.


    Result:-


    Now this returns "Sort" button object which is present under the parent directly. There are few more sorts but this is first catch.


     


    FindChild ("Sort" button)


    -------------------------------------------------------


    This methods finds/searches for required object (only 1 desired object) only under the child objects of objParent. The search is started from child objects of objParent and continues down the object hierarchy to the specified depth.


    Result:-


    Now this returns "Sort" button object present in the "Name" column of the header of main table. This methods ignore the parent


     


    FindAll ("Sort" button)


    --------------------------------------------------------


    This methods finds/searches all objects of desired prop-values in Parent and its children objects


    Result:-


    Now this returns all "Sort" button objects present iunder the parent and its childrens also. The search is started from objParent and continues down the object hierarchy to the specified depth.


     


    FindAllChildren ("Sort" button)


    ---------------------------------------------------------


    This methods finds/searches all objects of desired prop-values in parent's children objects only (parent is ognored). The search is started from child objects of objParent and continues down the object hierarchy to the specified depth.


    Result:-


    Now this returns all "Sort" button objects present iunder the parent and its childrens also. The search is started from objParent and continues down the object hierarchy to the specified depth.


     


    Hope this helps you.




  • Hi vallalarasu,

    Sorry about the wrong attachment. Please find the new one.

    Kindly vote for my reply if my responses were helpful.
  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor
    The output of each find is not the same.. Some are array, Few are variable and Can be more clear about it. 



    I experienced All the "Find" methods can't be used at all times.



    Can you be more specific
  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor
    Thanks for your response..This is better understandable than the previous one....



    But not the attachement .. He He He ..!
  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor
    I have  a situation here. Im Creating function by finding the objects using any of the find method. I'm going to use the functions across all the project or webpages. So the find performs as per the DEPTH used. It changes changes and  the function fails. If I use a depth of huge number as 1000 or more, it finds it. But the execution is very slow.





    Please help me how to resolve it??
  • Hi vallalarasu,



    The depth cannot be somthing big like 1000.

    Can you be more specific on the depths you are finding the object. please post few examples.



    In case depth is your only problem, keep the depth incrementing. ex as below



    var arrNames = new Array("name", "class", "visible");

    var arrValues = new Array("show", "button", true);

    var intDepth = 0;

    do

    {

        
    intDepth ++;

        var objChild = FindChild(arrNames, arrValues , intDepth, true);

    }while(!objChild.Exists)



    hope this helps. If not please provide more details about the problem.








  • Vallalarasu_P's avatar
    Vallalarasu_P
    Frequent Contributor
    It take lot of time than the normal one as i said.... Because for every value of Depth, it has to find the object and its bad. If most advanced sites like flight booking or any other has this issue.



    I'm creating a framework that find the object everytime using FIND .. So it take lot of time.