cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
Contributor

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 2
Highlighted
Regular Contributor

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

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
Highlighted
Community Hero

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

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.

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare images using the Region Checkpoint

See replies!

Converting UTC TimeDate in an Excel file

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors