Forum Discussion

ameykhopade's avatar
ameykhopade
Contributor
8 years ago

How can I use the waitchild method here to check if the object is available or not. OR any otherway.

i am testing a web application and using a datadriven framework which takes inputs from the couple of excel sheet.

1. One excel sheet contains the Full names of the objects and variables mapped to this full name.

2. other excel sheet contains the mapped names and the actions to be performed on the objects.

 

the frame work creates a command using both the excels to be executed using the mapped name of the object.

 

 

I am building a command to execute from "Func_BuildCommandLine" passing an excel sheet as a parameter

 

'Build the strCommandLine

strCommandLine = func_BuildCommandLine(Driver2)
sys.Refresh()

 

 that function returns value of strCommandLine =  "Call Sys.Browser("iexplore").Page("*").Form("aspnetForm").Panel("divHeaderAndContent").Panel("contentWrapper").Panel("LoginBar").Table(0).Cell(2, 1).SubmitButton("ContentPlaceHolder1_cmdSubmit").Click"

 

and later the command is executed as

'Execute the Command Line right here

Execute(strCommandLine)

Before executing the Command I need to make sure the object exists as sometimes it takes more time to load the page and the test is timeout before the object is loaded.

is there any way to make sure the object is available to click or perform any action.

 

 

Is there any method which takes the full name as parameter and checks its availability before performing the action 

2 Replies

  • Manfred_F's avatar
    Manfred_F
    Regular Contributor

    You can do this.

    I've Extended the facilities of aqObject.GetPropertyValue to accept constant arguments and also dots in the PropertyName string.

     

    Here is my code example, maybe You can use it for orientation purposes.

    It recursively navigates down the propertyname(arg1).SubProperty(arg2, arg3) ... tree to finally reach the desired Level.

    What is missing is to wait at each Level for an appropriate time, if necessary.

     

       Function GetPropertyValue( _
       myObj, _
       ByVal PropertyName, _
       ByVal Routine _
       )
       ' GetPropertyValue-Funktion, die auch untergeordnete Objekteigenschaften auswertet:
       ' PropertyName darf Punkte enthalten und einzelne Argumente
       Const cRoutine = "GetPropertyValue"
       Dim Ergebnis
       Dim Pfad
       Dim Ziel, ZielTxt, ArgAro
       Dim TmpObj
       Dim ErrLock   
       Dim Ts
    '         Set Ts = PVA_0.Debug.gCallInfo(mcModul & cRoutine).Activate(PropertyName, False, False)
          Set mZielObj = Nothing
          If Me.IsSupported(myObj, PropertyName, PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)) Then
    '            Ts.Keep "IsSupported True "
             Pfad = Split(PropertyName, ".")
             ' global, aus IsSupported
             Set TmpObj = mZielObj
             Set mZielObj = Nothing
             Ziel = Pfad(uBound(Pfad))
             ZielTxt = Ziel
             Set ArgAro = ArgumentAro(Ziel)
             If Util.ObjectIsSet(ArgAro) Then Ziel = ArgAro(0)
    
             ' kann trotzdem fehlschlagen
             On Error Resume Next
             Set ErrLock = PVA_0.TcLog.ErrorLock(PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine))
             If ArgAro Is Nothing Then
                Util.Zuweisen Ergebnis, aqObject.GetPropertyValue(TmpObj, Ziel)
    'log.Warning "4" & Ergebnis, cRoutine
                ' JS Properties als Methoden implementiert, aufrufen
                If Typename(Ergebnis) = "JScriptTypeInfo" Then
                   If instr(Ergebnis, "function(") = 1 Then
                      Util.Zuweisen Ergebnis, aqObject.CallMethod(TmpObj, Ziel)
                   End If
                End If
             ' mit Argument
             Else
                Err.Clear
                Util.Zuweisen Ergebnis, aqObject.GetPropertyValue(TmpObj, Ziel, ArgAro(1))
                If Err.Number <> 0 Then
                   Err.Clear
                   Util.Zuweisen Ergebnis, aqObject.CallMethod(TmpObj, Ziel, ArgAro(1))
                End If
             End If
    '            Ts.Keep "Zugriff "
             If Err.Number <> 0 And PVA_0.TcLog.Level(3) Then _
                log.Warning "Fehler bei Zugriff auf " & PropertyName, Err.Description & vbCr & PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)
             ErrLock.Restore
             On Error GoTo 0
    
          ' nicht gefunden
          ElseIf PVA_0.TcLog.Level(3) Then
    '            Ts.Keep "IsSupported False "
             Log.Warning "Methode nicht gefunden", "Name: " & PropertyName & vbCr & PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)
          End If   
          Util.Zuweisen GetPropertyValue, Ergebnis
    '         Ts.EndCall PropertyName
       End Function
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    a) Quick and somewhat dirty approach: replace required object references in your Excel file with their WaitXXX equivalences. E.g.: as per your example, replace "Panel("divHeaderAndContent")" with "WaitPanel("divHeaderAndContent", 10000)" to wait up to 10 seconds for the 'divHeaderAndContent' panel;

    b) As suggested by Manfred, parse obtained command string and recursively wait for the target object to appear.