QTP Script 1 – How to launch a QTP application, open a new test and close QTP through a script
This below code launches QuickTest Professional.
1. I made a folder with the name ‘qtp’ under c:\
2. I wrote the below code in a notepad file and saved it as launch.vbs under c:\qtp
3. Now I went to command prompt (Start->All Programs->Accessories->Command Prompt). On the C:\> prompt I wrote:
4. The command prompt now was:
5. Then I wrote file name (launch.vbs) and hit enter. It launched QTP Application.
We first create an instance of an object and its reference is stored in a vbscript variable (like first two lines of the code below). Then we can access methods and properties of an object using variable.method_name and variable.property_name
For Example to open a word application and to get its version, use the below code. Write it in a notepad, save it as .vbs file and run it.
Set WordApp = CreateObject(“word.application”)
WordApp.Application.Visible = True