Methods to Open an Application in QTP or VB Script

0
32
Spread the love
  • 13
  • 23
  • 12
  • 19
  •  
  •  
  •  
  •  
  •  
  •  
    67
    Shares

 

Methods to Open an Application in QTP or VB Script
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

Syntax:

SystemUtil.Run ( Name of the file to open, arguments, path, operation )

Argument Details:

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:

Operation Description
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
print This command is responsible for printing an file

code:


SystemUtil.Run "E:My DocumentTest.txt","","E:My DocumentDetails","open"

We can create variables to pass these information as well.Also check out here for common issues with SystemUtil.Run method.

InvokeApplication

This command is used with the older versions of QTP to support backward compatibility

Syntax:

InvokeApplication(“Full path of the app”,”full URL of the target”).
While the first argument is mandatory ,the second argument is optional.

Example:


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.
Example:


Dim oMyShell
oMyShell=CreateObject("WScript.shell")
//Create a "WScript.shell" object.
oMyShell.run "notepad.exe"

 

4.Manual Process:

Physically enter the lines to enter the data to run the application, and click on the the “OK” button.
Code:


Dialog("Run").WinEdit("Open:").Type "C:Windowsnotepad.exe"
Dialog("Run").WinButton("OK").Click
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 13
  • 23
  • 12
  • 19
  •  
  •  
  •  
  •  
  •  
  •  
    67
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here