Pages

Showing posts with label SystemUtil Object. Show all posts
Showing posts with label SystemUtil Object. Show all posts

Tuesday, November 13, 2012

Quick Test Professional (QTP) - Utility Objects

QTP provides several utility objects to enhance the power of scripting. Below is a list of all QTP utility objects.

Crypt, DataTable, Description, DTParameter, DTSheet, Environment, Extern, OptionalStep, Parameter, PathFinder, Properties(Collection), QCUtil, Random Number, Recovery, Reporter, Services, Setting, TextUtil, TSLTest, XMLUtil

Only some of the QTP objects are covered here and rest will be covered in other post.


Quick Test Professional (QTP) - SystemUtil Object


This is used to run and close the processes. Below are few example of starting the processes.

'Run internet explorer
SystemUtil.Run "iexplore.exe"

'Run the internet explorer and pass the staring URL
SystemUitl.Run "iexplore.exe", "http://www.yahoo.com"

Below are few examples of closing a process.

'Give # of closed process
numClosed = SystemUtil.CloseProcessByName("explore.exe")

'Title with a regular expression
SystemUtil.CloseProcessByWndTitle "Microsoft Internet Explorer. *", True

'Title without regular expression
SystemUtil.CloseProcessByWndTitle "Notepad"

'Closing a process by window handle
hwnd = Browser("creationtime:=0").GetROProperty("hwnd")
SystemUtil.CloseProcessByHwnd hwnd

'Close process by the process id
SystemUtil.CloseProcessById processID

'Close all processes opened by QTP
SystemUtil.CloseDescendentProcesses