|
用find()方法通过进程Id,获取TestObject ,但是取不到,请高手指点一下,代码如下:
--------------------------------------------
Dim ntpdProcess() As Process
Dim pid As Integer
Dim hnd As Long
'Dim fetionWin1 As TopLevelSubitemTestObject
ntpdProcess= Process.GetProcessesByName("notepad")
pid = ntpdProcess(1).Id()
hnd = ntpdProcess(0).Handle
MsgBox(fetion.Length()) '---return 2 ,如果已启动两个Notepad进程
'----------------------
Dim root As RootTestObject
Dim ftWin() As TestObject
root = RootTestObject.GetRootTestObject()
'ftWin = root.Find(AtList(AtProperty(".processId", pid)))
ftWin = root.Find(AtList(AtProperty(".processId", pid), AtDescendant(".domain", "Win")))
'ftWin = root.Find(AtChild("Handle", hnd, ".domain", "Win"))
MsgBox(ftWin.Length()) '----return 0(这里为什么会找不到?请帮忙看看)
------------------------------------------------------------
Thanks in advance! |
|