Forum Discussion

maxthomassin's avatar
maxthomassin
Occasional Contributor
13 years ago

Help with method Find()

Hello everyone,



im new to TestComplete and i need to find an object in a table using the find method with multiples properties. I'm trying to use it like in the example, but it's not working. Can someone give me a hand?




    var  arProp, arValue;


    arProp = new Array("outerText", "innerText");


    arValue = new Array("12155*", "12155*");


    


    item = all.Find(arProp, arValue);


    if (item.Exists)


    {


      Log.Message("Found! " + item.Name + "\r\n\r\n" + item.innerText);


    }


    else


      Log.Warning("Not found!"); 



I get the error : The parameter is incorrect on line 26 (where is the Find command)



Thanks you !



Maxime Thomassin
  • Do you really need to find an object using both outerText and innerText properties? Maybe you should use just innerText? The Page object has another find method that is more relevant for web pages - Page.NativeWebObject.Find.
  • It might be that the 'innerText' and/or 'outerText' values (with the wildcard) find more than one item.



    If not, maybe try this:




        var  arProp, arValue;


        arProp = new Array("outerText", "innerText");


        arValue = new Array("12155*", "12155*");


        


        item = all.Find(arProp, arValue).Exists;


        if (item == true)


        {


          Log.Message("Found! " + item.Name + "\r\n\r\n" + item.innerText);


        }


        else {


          Log.Warning("Not found!"); 

        }









  • If that doesn't work, try adding depth and refresh parameters to check deeper:



    item = all.Find(arProp, arValue,10,true).Exists;








  • Hi Maxime,


     


    Please answer the following questions to help us better understand what is going on:


    1. What kind of application are you testing? Web app?


    2. What TestComplete version are you using?


    3. Where is the all variable declared?


     


  • The problem is with the line 'item = all.Find(arProp, arValue);'.

    Change the 'all' to 'Aliases.wherevertheopbjectismapped'.



    For instance, if your table is mapped as "Aliases.Table", you would write it as follows:



        var  arProp, arValue;


        arProp = new Array("outerText", "innerText");


        arValue = new Array("12155*", "12155*");


        


        item = Aliases.Table.Find(arProp, arValue);


        if (item.Exists)


        {


          Log.Message("Found! " + item.Name + "\r\n\r\n" + item.innerText);


        }


        else


          Log.Warning("Not found!"); 



    Hopefully that works.

  • maxthomassin's avatar
    maxthomassin
    Occasional Contributor
    Thanks for your answers, im using TC version 7 and im testing Web Pages.

    My variables are declared 2 or 3 lines before.



    the variable all is the Aliase



    var all;

    all = Aliases.iexplore.pageSipadAccueil.document.all;
  • maxthomassin's avatar
    maxthomassin
    Occasional Contributor
    Well, im not going to use outerText and innerText in my real program. It was just for a test and it's not working