Forum Discussion

ArmandsBruns's avatar
ArmandsBruns
Frequent Contributor
12 years ago

Function (Find Object in NameMapping)

Hi,



I have function:



This function works fine the only problem is the log error.


 



If there are many objects with the same values (typeID and name), then click on them and then displays an error that the object is out of the window size.

 


Maybe I can use adisional 'VisibleOnScreen = True Then object(i).Click'

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

Function IfObjectExists(location, typeID, name)

 

  IfObjectExists = False

 

  Sys.Refresh()

  location.RefreshMappingInfo

 

  Do

    counter = counter + 1



      Sys.Refresh()

      location.RefreshMappingInfo

      

    If(location.FindChild( typeID, name,30).Exists <> Empty ) Then

      IfObjectExists = True

      log.Message("Find this object - '"+typeID+"', '"+name+"' - and click!")

      

      object = location.FindAllChildren(typeID, name, 20000, True)



      For i = 0 to UBound(object)

        If object(i).Exists Then object(i).Click

      Next

   

      Log.Message "Find: " & (UBound(object) + 1)

      Call location.Wait



    Else

      IfObjectExists = False

      aqUtils.Delay(2000)

      Sys.Refresh()

      location.RefreshMappingInfo    

      log.Message ("Doesn't find this objects: '"+typeID+"', '"+name+"'")

    End If



  Loop Until IfObjectExists = True or counter > 25



End Function

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



Regards

Armands

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Armands,


     


    I suppose, the issue is caused by unreliable Name Mapping criteria used in your project - an invisible object matches the recognition criteria specified for the object, and therefore, TestComplete fails to click it. Check the Name Mapping criteria for the problematic object and try adding the Visible=true criterion to them (or make sure that only a single object matches the criteria).


     

  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor


    Hi Tanya,



    Thanks for your response.



    I add aditional (Visible=True)

    Now it is much better than it was (always find and clikc on object), but sometimes still displays the same error. "The window size is (1, 1); screen rectangle: the left top corner is (0, 102), the right bottom corner is (0, 102).

    The screen coordinates of the point is (0, 102)."



    any ideas?




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

    Function IfObjectExists(location, typeID, name)

     

      IfObjectExists = False

     

      Sys.Refresh()

      location.RefreshMappingInfo

     

      Do

        counter = counter + 1



          Sys.Refresh()

          location.RefreshMappingInfo

          

        If(location.FindChild( typeID, name,30).Exists <> Empty ) Then

          IfObjectExists = True

          log.Message("Find this object - '"+typeID+"', '"+name+"' - and click!")

          

          object = location.FindAllChildren(typeID, name, 20000, True)



          For i = 0 to UBound(object)

            If object(i).Exists and object(i).Visible=True Then

            object(i).Click

            log.message("click to object")

          Next

       

          Log.Message "Find: " & (UBound(object) + 1)

          Call location.Wait



        Else

          IfObjectExists = False

          aqUtils.Delay(2000)

          Sys.Refresh()

          location.RefreshMappingInfo    

          log.Message ("Doesn't find this objects: '"+typeID+"', '"+name+"'")

        End If



      Loop Until IfObjectExists = True or counter > 25



    End Function

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



    Regards

    Armands