RegisterUserFunc 重写QTP自带对象的方法
2014-03-19 00:56
447 查看
RegisterUserFunc:为测试对象添加一个新的自定义方法,或者重写测试对象已有的方法
语法:RegisterUserFuncTOClass, MethodName, FunctionName, SetAsDefault
说明:
TOClass 想要注册方法的对象
MethodName 想要注册的方法名称
FunctionName 函数中自定义的函数名称
SetAsDefault 是否要注册为对象的默认操作,值为:False,或者True
'Register the userdifine method, put below code into keywordlibrary(generally)
RegisterUserFunc "Window", "CheckObjectExist","CheckObjectExist",false
Function CheckObjectExist(strObj)
Dim obj : set obj = strObj
If obj.Exist Then
Reporter.ReportEvent micPass,"Verify Object exist","Objectexist"
Else
Reporter.ReportEvent micFail,"Verify Object exist","Object notexist"
End If
End Function
'after that window object can use the CheckObjectExist methodin ur test case(just press Dot key behind the Object. and u can see the method in the droplist)
Window("Window_FlightReservation").CheckObjectExist
以上实例是个简单的自定义对象方法的例子
语法:RegisterUserFuncTOClass, MethodName, FunctionName, SetAsDefault
说明:
TOClass 想要注册方法的对象
MethodName 想要注册的方法名称
FunctionName 函数中自定义的函数名称
SetAsDefault 是否要注册为对象的默认操作,值为:False,或者True
'Register the userdifine method, put below code into keywordlibrary(generally)
RegisterUserFunc "Window", "CheckObjectExist","CheckObjectExist",false
Function CheckObjectExist(strObj)
Dim obj : set obj = strObj
If obj.Exist Then
Reporter.ReportEvent micPass,"Verify Object exist","Objectexist"
Else
Reporter.ReportEvent micFail,"Verify Object exist","Object notexist"
End If
End Function
'after that window object can use the CheckObjectExist methodin ur test case(just press Dot key behind the Object. and u can see the method in the droplist)
Window("Window_FlightReservation").CheckObjectExist
以上实例是个简单的自定义对象方法的例子
相关文章推荐
- RegisterUserFunc为测试对象添加新方法或重写已有方法
- RegisterUserFunc为测试对象添加新方法或重写已有方法
- 在QTP中使用RegisterUserFunc
- 如何改写QTP自带方法来同时操作多个子对象
- PHP面向对象之方法重写与重载
- 在重写了对象的equals方法后,还需要重写hashCode方法吗?
- qtp运行时,缺少对象Wscript的解决方法
- 重写QTP的Reporter方法
- 解决php smarty 2.x register_object方法不支持多级对象方法调用的问题
- QTP对象的一些隐藏的属性和方法
- JDK中自带xml和对象互转方法
- 5、面向对象以及winform的简单运用(方法重载、隐藏、重写与虚方法)
- JAVA正确地自定义比较对象---如何重写equals方法和hashCode方法
- QTP的那些事--DOM的几种内置的获取对象方法
- 在QTP中巧用WebTable对象的ChildItem方法进行测试
- QTP 检查对象的存在的优化方法
- HashMap将对象作为key为什么需要重写equals和hashcode方法
- python-对象、私有属性_方法、继承(多重继承)、重写
- 关于(qtp)Reporter对象的ReportEvent方法
- PHP中通过调用call_user_func_array函数执行mysqli_stmt_bind_param方法时需要注意的问题