Forum Discussion

jack_edwards's avatar
jack_edwards
Occasional Contributor
9 years ago

How to get IsSupported to return False for stub objects?

Like the title says, I would like to have the IsSupported method (or some similar method) to return False when a stub object does not have a given property.  The reason for this is we are trying to verify whether an Alias exists in our name mapping.  Using the IsSupported method seems to work, up until we start dealing with stub objects (the objects are not in the object tree, but are in our name mapping file).

 

I realize this is more of a feature request, so my reason for posting here is to just try and find a different way of doing this.

 

Here is the script we are working with.  This script works as long as "currObj" exists in the object tree.  We get the error message that we want.  The error message does not get posted, though, if we try running the function without our browser open.  Every object becomes a stub object, which causes the IsSupported method to return True for everything.

Function Validate
    
    'Good alias
    'name = "Aliases.Browser.Page.Section.Field"
    
    'Bad alias
    name = "Aliases.Browser.Page.Field"
    
    arr = split(name, ".")
    If arr(0) <> "Aliases" Then
        Log.Error "Error.  This is not an alias: " & name
        Exit Function
    End If
    
    objName = "Aliases." & arr(1)
    Set currObj = Eval(objName)
    For i = 1 to UBound(arr) - 1
        If aqObject.IsSupported(currObj, arr(i + 1)) Then 'This always returns True for stub objects
            Log.Message "is supported"
            objName = objName & "." & arr(i + 1)
            Set currObj = Eval(objName)
        Else
            Log.Error "Aliases name does not exist."
            Exit Function
        End If
    Next
    
End Function

Is there any way to get IsSupported to return false for stub objects?  Is there a different method we can use that would mimic this functionality?

  • HKosova's avatar
    HKosova
    9 years ago

    Jack,

     

    IsSupported = True for stub objects is by design and documented.

     


    jack_edwards wrote:

     

    The simplest solution, we think, is to just modify the script to work around the Auto-wait timeout.


    Yes, that's probably the best way to handle this. Set Options.Run.Timeout to 0 at the beginning of your validation function, and restore the initial value at the end.

    • jack_edwards's avatar
      jack_edwards
      Occasional Contributor

      Helen,

       

      This is actually the code we were using until just recently.  The issue with this code, though, is it takes extremely long to process when the Aliases do not exist in the object tree.

       

      Every time "aqObject.GetProperties(obj, True)" gets called, TestComplete tries to find the Alias in the object tree.  If the Alias does not exist in the object tree, then TestComplete waits for the amount of time setup in Current Project Properties > Auto-wait timeout, which is 10 seconds by default, multiplied by however many parts of the Alias are not in the object tree.

       

      For example, if we are trying to validate Aliases.Browser.Div.Section.Panel.Form.Input, but "Div" does not exist, then we wait for 40-50 seconds to find out whether or not the Alias is a valid Alias.  Since our tests perform this check on every Alias, this can waste a lot of time when our test fails due to missing objects on the screen.

       

      Reducing this timeout to 1 second or even 0 seconds would resolve this issue, but many of our tests rely on this timeout being in place.  The simplest solution, we think, is to just modify the script to work around the Auto-wait timeout.

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Jack,

         

        IsSupported = True for stub objects is by design and documented.

         


        jack_edwards wrote:

         

        The simplest solution, we think, is to just modify the script to work around the Auto-wait timeout.


        Yes, that's probably the best way to handle this. Set Options.Run.Timeout to 0 at the beginning of your validation function, and restore the initial value at the end.