gpt4 book ai didi

vbscript - 获取QTP中调用注册函数的对象类型

转载 作者:行者123 更新时间:2023-12-04 05:01:59 25 4
gpt4 key购买 nike

我正在尝试开发一个通用的注册函数来验证给定对象的存在,然后在报告中添加一行以说明它是否被找到。

这是函数:

'@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

最佳答案

尝试使用 test_object.GetTOProperty("micclass")用于测试对象的名称。
一些动态对象(例如从 ChildObjects 返回的那些)可能没有在 QTP 端设置这个属性,在这种情况下你应该做 test_object.GetROProperty("micclass") .

RO 方法应该总是有效,但它比 慢一点至 应该几乎总是有效的方法。

关于vbscript - 获取QTP中调用注册函数的对象类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16047008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com