Can QTP automate VC++ Application?
I've client server application that is developed in VC++. Can someone tell me if i can automate it with uft 11.5? I did some research and found that QTP 9.5 and 10.0 can't automate it but i'm wondering if we can automate it with later versions of QTP. Your input will be greatly appreciated.
Thanks in Advance
In my limited experience the language used to create the application is not the gating factor in the ability to automate testing with QTP/UFT. Usually there is some other technology involved in the application that may cause problems. What other technologies are used in your application? Have you looked at the Product Availability Matrix to see what technologies and versions are supported by the UFT add-ins?
(Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)
To some extent you can automate using QTP with no add ins loaded. QTP will identify all objects as "WINDOWS" object but menus will not get identified, you will have to use unreliable methods like gettextlocation, etc to hit a particular menu item. This example is applicable for Out of Box functionality of QTP.
A Second option is to Enhance your Function Libraries using the Windows API
In MSDN, locate the function you want to use in your function library.
Read its documentation and understand all required parameters and return values.
Note the location of the API function. API functions are located inside Windows DLLs. The name of the DLL in which the requested function is located is usually identical to the Import Library section in the function's documentation. For example, if the documentation refers to User32.lib, the function is located in a DLL named User32.dll, typically located in your System32 library.
Use the QuickTest Extern object to declare an external function. For more information, see the HP QuickTest Professional Object Model Reference.
The following example declares a call to a function called GetForegroundWindow, located in user32.dll:
extern.declare micHwnd, "GetForegroundWindow", "user32.dll", "GetForegroundWindow"
Call the declared function, passing any required arguments, for example:
hwnd = extern.GetForegroundWindow().
In this example, the foreground window's handle is retrieved. You can enhance your function library if the foreground window is not in the object repository or cannot be determined beforehand (for example, a window with a dynamic title). You may want to use this handle as part of a programmatic description of the window, for example:
In some cases, you may have to use predefined constant values as function arguments. Since these constants are not defined in the context of your function, you need to find their numerical value to pass them to the called function. The numerical values of these constants are usually declared in the function's header file. A reference to header files can also be found in each function's documentation under the Header section. If you have Microsoft Visual Studio installed on your computer, you can typically find header files under X:\Program Files\Microsoft Visual Studio\VC98\Include.
For example, the GetWindow API function expects to receive a numerical value that represents the relationship between the specified window and the window whose handle is to be retrieved. In the MSDN documentation, you can find the constants: GW_CHILD, GW_ENABLEDPOPUP, GW_HWNDFIRST, GW_HWNDLAST, GW_HWNDNEXT, GW_HWNDPREV and GW_HWNDPREV. If you open the WINUSER.H file, mentioned in the GetWindow documentation, you will find the following flag values:
* GetWindow() Constants
#define GW_HWNDFIRST 0
#define GW_HWNDLAST 1
#define GW_HWNDNEXT 2
#define GW_HWNDPREV 3
#define GW_OWNER 4
#define GW_CHILD 5
#define GW_ENABLEDPOPUP 6
#define GW_MAX 6
The following example retrieves a specific menu item's value in the Notepad application:
' Constant Values:
const MF_BYPOSITION = 1024
' API Functions Declarations
Extern.Declare micInteger,"GetMenuItemCount","user32.dll","GetMen uItemCount",micHwnd
Extern.Declare micHwnd,"GetSubMenu","user32.dll","GetSubMenu",mic Hwnd,micInteger
Extern.Declare micInteger,"GetMenuString","user32.dll","GetMenuSt ring",micHwnd,micInteger,micString+micByRef,micInt eger,micInteger
hwin = Window("Notepad").GetROProperty ("hwnd")' Get Window's handle
' Use API Functions
men_hwnd = Extern.GetMenu(hwin)' Get window's main menu's handle
item_cnt = Extern.GetMenuItemCount(men_hwnd)
hSubm = Extern.GetSubMenu(men_hwnd,0)
rc = Extern.GetMenuString(hSubm,0,value,64,MF_BYPOSITIO N)
I don't build Software but I make them work better, Testing is a Passion
Thanks guys for your replies!
@tclasp - Its a VC++ with Oracle Database.
@tclasp - Its a VC++ application with Oracle database