Jonas
Jonas

Reputation: 198

Checkpoint Validate non existence of Object

We are testing an GUI with UFT 14.52. For each Popup, Schema, View we have an single Component. I would like to add validations points for each component, so i can validate that the application is in the right state.

For Example: I do have this Popup and an Component which handles the Popup (selecting street, and clicking buttons).

Popup

When the Component starts, i want to verify that the Popup is up. With UFT Checkpoints this works flawless by using enabled as identification.

enabled as identification

But if i want an verification point at the end (Check if the Popup is closed via enabled) i do get an "object not found exception from uft" as expected, because the given popup is closed. Validing the object is not existing by JavaObject.Exist(5) is not feasible because it will actually wait the timeout and then return the state.

Is there any workaround for this? Is there something similar as javaObject.NonExists(5)? Is this state validation at the end even useful?

Upvotes: 1

Views: 609

Answers (1)

Motti
Motti

Reputation: 114685

One thing to note is that the timeout parameter to Exist doesn't default to zero, so if you want it to return right away if the object doesn't exist you should use obj.Exist(0).

If my understanding is correct, you want to mimic the behaviour of Exist so that if the condition fails (the object does exist in this case) then the function doesn't return False immediately but waits the timeout for it to become True (for the object not to exist).

If so you can try this:

Public Function NotExist(ByRef test_object, ByVal timeout)
       Deadline = DateAdd("s", timeout, Now)
       While test_object.Exist(0)
            If DateDiff("s", Now, Deadline) < 0 Then
                NotExist = False
                Exit Function
            End If  
            test_object.RefreshObject ' not sure if this is needed
       Wend

       NotExist = True
End Function
RegisterUserFunc "JavaObject", "NotExist", "NotExist"

The only subtle part here is the RefreshObject which I thought was needed but it worked without it when I tried it with Web addin (I don't use Java).

I think it should be needed since UFT caches the object if it's found but perhaps Exist clears this cache (further reading on this caching mechanism).

Upvotes: 2

Related Questions