Thursday, February 17, 2011

Help getting QTP to identify a control

We're trying to use QTP (QuickTest Professional) to auto-test a legacy C++ application.

However, the main window for the app is composed of several IDENTICAL panels. Each panel has a unique title.

If I view the window in Spy++ (comes with DevStudio), I see:

+ Window <hwnd> "Window Title" taskwindowclass
  + Window <hwnd> "Panel A" childwindowclass
    + Window <hwnd> "OK" Button
  + Window <hwnd> "Panel B" childwindowclass
    + Window <hwnd> "OK" Button

In QTP's Object Spy however, the hierarchy shows as:

+ Window: Window Title
  + WinButton: OK

It doesn't even show that there is an intermediate panel.

Does anybody know a way to get the window "path" in order to identify each control? i.e. so the controls identify as:

Button A: "Window Title/Panel A/OK"
Button B: "Window Title/Panel B/OK"
From stackoverflow
  • You could use descriptive programming to bypass the object map. QTP will ignore panel objects by default. You could try to get a reference to the panel object dynamically, then search the ChildObjects collection to find the ok button. Another option might be to simply add an ordinal identifier to the ok buttons.

    • Button A: "Window Title/OK index #1"
    • Button B: "Window Title/OK index #2"

0 comments:

Post a Comment