Pages

Tuesday, November 13, 2012

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

No comments:

Post a Comment