有些对象用Object.Exist不起作用,因为是隐藏起来的所以用Object.Exist都是true
所以采用DOM里的currentStyle获取visibility来判断对象是否存在
1. update Obj_Exist(WaitSec)
2. Update OBJ_NOTExist
'------------------------------------------------------------------------------------------------------------------------
'Function Obj_Exist
'Description Obj_Exist
'Input WaitTime
'Output Obj_Exist
'------------------------------------------------------------------------------------------------------------------------
Function Obj_Exist(Parameter,Object)
On Error Resume Next
Err.Clear
visibleValue = Ucase(Cstr(Object.currentStyle.visibility)) 'Get the visibility value of the object
' Check if the object is not hidden and exist in <30> seconds.
StartTime = Time()
Do while visibleValue = "HIDDEN"
Wait(1)
visibleValue = Ucase(Cstr(Action_Object.Object.currentStyle.visibility))
FindObjectResult = Eval(Object & ".Exist(1)")
If FindObjectResult and visibleValue<>"HIDDEN" Then
Exit Do
End If
If CalculateTimeDuration(StartTime)>CInt(30) Then
Obj_Exist = "Error|" & FormatCurrentTime() & " Object not exist in " & WaitSec & " seconds. Error Number: "&Err.Number&" Error Description: "&Err.Description&"|"
Exit Function
End If
Loop
' Check if the object is not hidden and exist in <WaitSec> seconds.
If Err.Number = 0 Then
Obj_Exist = "Pass|" & FormatCurrentTime() & " Object is found successfully and visible.|"
Else
Obj_Exist = "Error|" & FormatCurrentTime() & " Unexpected Error occurred. Error: "&Err.Number&" Error Description: "&Err.Description&"|"
End If
End Function
'------------------------------------------------------------------------------------------------------------------------
'Function Check_OBJnotExist
'Description Check OBJnotExist
'Input Object string
'Output Check result
'------------------------------------------------------------------------------------------------------------------------
Function OBJ_NotExist(Parameter,Object)
On Error Resume Next
Err.Clear
FindObjectResult = False
FindObjectResult = Eval(Object&".Exist(1)")
If Err.Number <> 0 Then
OBJ_NotExist = "Failed|"&FormatCurrentTime()&" Unexpected error while FindObject. Error details: "&Err.description&"|"
Else
If FindObjectResult and UCase(Cstr(Action_Object.Object.currentStyle.visibility))<>"HIDDEN" Then
OBJ_NotExist = "Failed|" &FormatCurrentTime()&" Object still exists.|"
Else
OBJ_NotExist = "Pass|" &FormatCurrentTime()&" Object doesn't exist .|"
End If
End If
End Function