Sunday 18 August 2013

How to Launch an Application in QTP

There are four ways to launch an application. They are as follows -
1) SystemUtil.Run – SystemUtil.Run ( FileName, Parameters, Path, Operation )
FileName – The name of the file you want to run.
Parameters – If the specified FileName is an executable file, use the Parameters argument to
specify any parameters to be passed to the application.
Path – The default directory of the application or file.
Operation – The action to be performed. If this argument is blank (”"), the open operation is
performed.
Example –
systemUtil.Run “D:\My Music\Breathe.mp3″,”",”D:\My Music\Details”,”open”
2) InvokeApplication – This command is now mainly used for the backward compatability ie to use
with the lower versions(below QTP 6.0) of QTP.
Syntax -
InvokeApplication(”Full URL as Parameter”)
Example -
InvokeApplication “C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.yahoo.com
3) VBscript to invoke application
Dim oShellSet oShell = CreateObject (”Wscript.shell”)
oShell.run “F:\jdk1.3.1\demo\jfc\SwingSet2.bat”‘
oShell.run “java -jar F:\jdk1.3.1\demo\jfc\SwingSet2\SwingSet2.jar”‘
oShell.Run Chr(34) & “C:\Program Files\Internet Explorer\IEXPLORE.EXE” & Chr(34)Set oShell = Nothing
4) Trivial but useful method
You can use the Start -> Run dialog of Windows.
1. Add the Windows Start button to the Object Repository using the “Add Objects” button in
Object Repository dialog.
2. Open the Run dialog (Start -> Run), and learn the “Open” edit field and the “OK” button into the
Object Repository.
3. Switch to the Expert View, and manually add the lines to open the Run dialog.
Example:Window(”Window”).WinButton(”Button”).ClickWindow(”Window”).Type(”R”)
4. Manually enter the lines to enter the information to launch the application, and click the “OK” button of the Run dialog.
Example:
Dialog(”Run”).WinEdit(”Open:”).Type “c:\WINNT\system32\notepad.exe”
Dialog(”Run”).WinButton(”OK”).Click

No comments:

Post a Comment