|Methods to Open an Application in QTP or VB Script|
Methods to Open an Application in QTP or VB Script
A lot of time we the automation test engineers need to face this situation that we need to open an application through our script. It is a sophisticated approach to open the application during run time.This is also very important concept while building complex framework. This one of the major challenge in Test solution design.
This post talks about different methods to launch our application :
SystemUtil.Run ( Name of the file to open, arguments, path, operation )
Name of the file to open – The target file to open
Parameters – Predetermined File Name (may an .exe file), this is used in case the application takes any.
path- The catalog of the files or application .
Operations – The activities can be done.
Here are list of operations that can be done:
|Open||This command is responsible for opening the executable or non executable file/application or something. It is default.|
|edit||This command is responsible for opening the executable or non executable file/application or something in the default editor.|
|explore||This command is responsible for exploring the file folder|
|find||This command is responsible for starting a file search operation of the windows|
|This command is responsible for printing an file|
SystemUtil.Run "E:My DocumentTest.txt","","E:My DocumentDetails","open"
This command is used with the older versions of QTP to support backward compatibility
InvokeApplication(“Full path of the app”,”full URL of the target”).
While the first argument is mandatory ,the second argument is optional.
InvokeApplication "E:Program FilesInternet ExplorerIEXPLORE.EXE google.com"
shell object or VBscript way to invoke applications:
Once shell object is created we need to utilize run method to launch the exe or application. we need to further utilize Chr(34) in case we have space in the path.finally release the memory held by the object.
Dim oMyShell oMyShell=CreateObject("WScript.shell") //Create a "WScript.shell" object. oMyShell.run "notepad.exe"
Physically enter the lines to enter the data to run the application, and click on the the “OK” button.
Dialog("Run").WinEdit("Open:").Type "C:Windowsnotepad.exe" Dialog("Run").WinButton("OK").Click