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
以上實例是個簡單的自定義對象方法的例子