Forum Discussion

Vivek72's avatar
Vivek72
Contributor
11 years ago
Solved

how to set variable to UIA object index?

Hi,



I got a script where object is identified only as UIA object as test complete is not recognising these objects as silverlite as it is supposed to be. I am using UIA object properties to run the script which is fine with me. The Child objects are named as


UIAObject("Equals"), UIAObject("Equals_2"),UIAObject("Equals_3")and so on. I need to put checkpoint here to select these objects but not knowing how and where to put variable in the script to replace those indexes using VB script. Please help.


  • The following example shows how to append a variable to a text string in VB:




    For i = 1 To 3


        Log.Message("Equals_" & i)


     Next

3 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    You have to use WaitUIAObject method to get the maximum index number.

    Just iterate through items increasing the index until you find the object which doesn't exist. It should look something like this:




    Function GetMaxObjectIndex()


      Index = 1


      While Sys...WaitUIAObject("Equals_" & i, 10).Exists


        Index = Index + 1


      Wend


      GetMaxObjectIndex = Index


    End Function  




     

  • karkadil's avatar
    karkadil
    Valued Contributor
    The following example shows how to append a variable to a text string in VB:




    For i = 1 To 3


        Log.Message("Equals_" & i)


     Next

  • Thanks to Gennadiy,



    The above solution WORKS fine. Now i have some other issue with same checkpoint.

    For i = 2 to j

    Set Equals = Sys... UIAObject("Equals_" & i)

    If i = j then

    Equals.Click

    Exit For

    End If

    Next



    In the above checkpoint, I need to give 'j' maximum value that exists which means j is greater than any value of i. Here, j value is not consistent. So, how to set j value... using expression?

    Thanks in advance again.