51Testing软件测试论坛

标题: 在QTP中如何对进程进行操作? [打印本页]

作者: 每天喝水    时间: 2006-2-13 14:22
标题: 在QTP中如何对进程进行操作?
请赐教:
如果想通过QTP把一个进程给杀掉,那么在QTP中应该如何操作?
是写代码还是QTP本身就有此功能?
还是对杀进程进行录制?
作者: Horus_Ra    时间: 2006-2-14 13:22
我只知道恢复场景里可以杀进程……或许你可以利用一下?

或者录制一个任务管理器也很方便啊……

[ 本帖最后由 Horus_Ra 于 2006-2-14 13:23 编辑 ]
作者: 每天喝水    时间: 2006-2-16 14:46
标题: 南泥湾精神...自己的问题自己解决...
代码如下:

'========================================================'
'Closes a process according to its name.
'If multiple processes exist with the same name, they are all closed.

Dim i
Dim j

For i = 0 To 4

SystemUtil.Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")

Next

Wait(3)

j = SystemUtil.CloseProcessByName("IEXPLORE.EXE")

'The Return Value is tell us that how many processes of the same name have been closed at same time.
'The number of instances of the application that are closed when the statement runs.

If j = i Then
        Reporter.ReportEvent micPass, "SystemUtil.CloseProcessByName  passed", "j = " & j & ", i = " & i
Else
        Reporter.ReportEvent micFail, "SystemUtil.CloseProcessByName Fail", "j = " & j & ", i = " & i
End If
'========================================================='


红色部分是关键,功能请仔细看注释。




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2