我正在尝试开发一个通用注册函数来验证给定对象的存在,然后在报告中添加一行来说明它是否被发现。
这是功能:
'@Description Reports in the test results whether the given object exists.
Public Function verifyExistence(ByRef test_object)
If test_object.Exist(1) Then
Reporter.ReportEvent micPass, "Verify that the page exists.", "Page exists."
Else
Reporter.ReportEvent micFail, "Verify that the page exists.", "Page does not exist."
End If
End Function
RegisterUserFunc "Page", "verifyExistence", "verifyExistence"
这适用于 Page 对象,但我如何“泛化”它以便它可以与任何对象类型一起使用?我意识到我需要为每个对象类型添加一个 RegisterUserFunc 行。
理想情况下,我会有一条如下所示的行:
typename = getType(test_object)
if typeName = "Page" Then
objName = test_object.GetROProperty("title")
... 'and so on.
end if