According to the system documentation, QuickTest Professional supports a number of terminal emulators, the vendors including Attachmate, Hummingbird, IBM, NetManage, Seagull, WRQ and Zephyr. However there are a myriad of other vendors out there with terminal emulators that could manually be integrated with QTP. This document will go through the setup of one of these, namely the TN3270 Plus emulator.
However all emulators should work in more or less the same way. For the purposes of this example we will be using the Mercury Terminal Demo Server application. Note that in order to get the most benefit from the integration to QTP, the emulator must be based on HLLAPI, or variations thereof. This will enable QTP to recognize fields as objects and record them in the repository. The TN3270 Plus emulator uses WinHLLAPI.dll. In this example I am also assuming that the TE Add-in for QTP has been installed.
The process is relatively simple:
1. Install the terminal emulator. A trial version of the TN3270 Plus emulator can be downloaded from sdisw. After installing the emulator I started the Mercury server and opened a terminal window.
2. The next thing we need to do is set up the session in the emulator. Do this by going to Setup => Sessions. At the bottom right there is the WinHLLAPI Session ID. Change this to “A”. All other settings I just left at their default values.
3. Open QTP. Note that it is important that the emulator application is opened before QTP is opened, else QTP will not hook in to the emulator. Open the menu Tools => Options. Select the Terminal Emulator section. Click the Open Wizard button to start defining the emulator settings.
4. Click Next on the first page. Select the Configure a new user-defined setting option and enter a descriptive name for Vendor and Emulator. Click Next, Next.
5. Browse to the file that is used by the emulator (In this case it is “C:\Program Files\SDI\TN3270 Plus\Whllapi.dll”). The name of the file will be something along the lines of hllapi.dll, whllapi.dll, ehllapi.dll or ehllapi32.dll, etc. depending on the vendor used. Secondly we need to specify the name of the entry function for this dll file. This may be less obvious. If it is not documented you can get the info by interrogating the dll with a tool such as Dependency Walker. In our example, the name of the function is simply hllapi. Note that the function names are case sensitive. Lastly we select Classic as the HLLAPI format. Click Next.
6. You should now be presented with a preview window displaying the contents of the emulator screen. If you don’t see this it means that QTP is not able to connect to the emulator. Reasons may include an incorrectly-defined function name, emulator session not set to “A” or QTP having been opened before the emulator.
7. Next we need to point out the different screen components of the emulator window to QTP. Click the “hand” button for each one and then click the area of the window that you want to register. You should not need to configure the emulator screen (bottom checkbox), unless you are not using hllapi. Click Next.
8. Finally, you can save the configuration settings to a file if you want. Click Finish to complete the process. You should now be able to script against the emulator, with QTP recognizing fields and registering them in the repository. In some cases the fields are not registered automatically so you may have to add them to the repository manually. You can now do anything that would normally be able to do with a Windows app using the repository, such as checkpoints or using the GetROProperty methods.