覆盖 UFT 12.51 中的方法时发生未知错误
Unknow errors while overriding methods in UFT 12.51
审阅者周末快乐 :) 我在尝试为 link
、Image
& button
。我在 script.Would 的执行过程中遇到了一个未知错误,如果有人可以指导我,请多多指教。下面是我的代码
' Creating Browser description
' "title:=Work Transfer Management System - WTMS"
Set WTMSBrwsr = Description.Create
WTMSBrwsr("title").Value = "Work Transfer Management System - WTMS"
' Creating Page description
' "title:=Work Transfer Management System - WTMS"
Set WTMSPge = Description.Create
WTMSPge("title").Value = "Work Transfer Management System - WTMS"
'Creating link description
set OdescLnk= Description.Create
OdescLnk("Link").value="Engineering Work Placement"
OdescLnk("html tag").value="A"
Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
'function Lib
RegisterUserFunc "WebButton", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Link", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Image", "fnBtnClick", "fnBtnClick"
'Function Definition
Function fnBtnClick(objControl)
'Check if object exists
If objControl.Exist Then
'Check if the object is enabled or not
If objControl.GetROProperty("disabled") <> 0 Then
'Click on the button
objControl.Click
End If
End If
End Function
错误发生在Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
能不能帮我看看这是不是写方法使用方法?
与每个脚本一样,该脚本从上到下执行。
何时
Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
被执行,它会寻找那个函数的注册,但是那个不存在,因为代码
RegisterUserFunc "WebButton", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Link", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Image", "fnBtnClick", "fnBtnClick"
尚未执行。
所以将 RegisterUserFunc
调用移到顶部,它会起作用。
如果在 RegisterUserFunc
调用中引用其名称之前声明函数,也可能会提高代码的可读性,因此 最好也将函数定义移至顶部.
审阅者周末快乐 :) 我在尝试为 link
、Image
& button
。我在 script.Would 的执行过程中遇到了一个未知错误,如果有人可以指导我,请多多指教。下面是我的代码
' Creating Browser description
' "title:=Work Transfer Management System - WTMS"
Set WTMSBrwsr = Description.Create
WTMSBrwsr("title").Value = "Work Transfer Management System - WTMS"
' Creating Page description
' "title:=Work Transfer Management System - WTMS"
Set WTMSPge = Description.Create
WTMSPge("title").Value = "Work Transfer Management System - WTMS"
'Creating link description
set OdescLnk= Description.Create
OdescLnk("Link").value="Engineering Work Placement"
OdescLnk("html tag").value="A"
Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
'function Lib
RegisterUserFunc "WebButton", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Link", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Image", "fnBtnClick", "fnBtnClick"
'Function Definition
Function fnBtnClick(objControl)
'Check if object exists
If objControl.Exist Then
'Check if the object is enabled or not
If objControl.GetROProperty("disabled") <> 0 Then
'Click on the button
objControl.Click
End If
End If
End Function
错误发生在Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
能不能帮我看看这是不是写方法使用方法?
与每个脚本一样,该脚本从上到下执行。
何时
Browser(WTMSBrwsr).Page(WTMSPge).Link(OdescLnk).fnBtnClick
被执行,它会寻找那个函数的注册,但是那个不存在,因为代码
RegisterUserFunc "WebButton", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Link", "fnBtnClick", "fnBtnClick"
RegisterUserFunc "Image", "fnBtnClick", "fnBtnClick"
尚未执行。
所以将 RegisterUserFunc
调用移到顶部,它会起作用。
如果在 RegisterUserFunc
调用中引用其名称之前声明函数,也可能会提高代码的可读性,因此 最好也将函数定义移至顶部.