Onnesh
Onnesh

Reputation: 1189

in QTP, how to check whether a dialog is already open?

I have been using the following code to check whether a dialog is already open

If  Window(window_name).Dialog(dialog_name).Exist = False 
    Then '' //here qtp waits..
    Window(window_name).WinMenu("Menu").Select menu_name
End If

This code is to avoid reopening the same dialog during each run of the code. But the qtp run waits about 10 - 15 seconds & then goes to next step. in what way we can avoid this?

If the dialog is not open, then the menu will be clicked to open the dialog.

Upvotes: 2

Views: 12507

Answers (2)

Motti
Motti

Reputation: 114695

The Exist property accepts a value of how long to wait for the object to exist.

If Window(window_name).Dialog(dialog_name).Exist(60) = False

Upvotes: 5

sreeram
sreeram

Reputation: 11

The method mentioned is good. You can also try this method.

If (Window(window_name).Dialog(dialog_name)
  .winbutton(Btn_name).Getroproperty("abs_x"))

This returns true if the object exists if not it returns false.

Upvotes: 0

Related Questions