|
下面是一个我减化后的一个例子:
function Util_Object_ExistByTime(obj,iTimeOut)
Dim t
t=0
Util_Object_ExistByTime=true
While(obj.Exist(1)=false)
wait(1)
t = t+1
If t = iTimeOut Then
Util_Object_ExistByTime=false
Exit function
End If
Wend
End function
Function Util_Object_Set(obj,strValue)
Call Util_Object_SetByTime(obj,strValue,TIMEOUT)
End Function
Function Util_Object_SetByTime(obj,strValue,iTimeOut)
If Util_Object_ExistByTime(obj,iTimeOut) Then
On error resume next
obj.Set strValue
If Err.Number<>0 Then
reporter.ReportEvent micFail ,"SetError", "Error Number=" & Err.Number & ", Error Desc=" & Err.Description
end if
err.clear
On error goto 0
End If
End Function
' Run below before test start
' Registe WebEdit User Defined Function
RegisterUserFunc "WebEdit","SetText","Util_Object_Set",True
'RegisterUserFunc "WebEdit","Set","Util_Object_Set",True 这个应该直接可以覆盖的 可以试下 我也好久没碰QTP 不记得了
RegisterUserFunc "WebEdit","SetByTime","Util_Object_SetByTime",True
' Run below after test end
' Unregiste WebEdit User Defined Function
UnRegisterUserFunc "WebEdit","SetText"
UnRegisterUserFunc "WebEdit","SetByTime"
[ 本帖最后由 lantianwei 于 2009-8-14 13:09 编辑 ] |
|