[英]Could no use registered function in UFT/QTP
我将以下功能与测试相关联,以便在行文本与期望值匹配时在java表中选择一行:
Public Function GetRowWithCellText(ByRef oJTable, sColName, sText)
bChkText=FALSE
iRowCount=oJTable.GetROProperty("rows")
For iCounter=0 to iRowCount-1
sGetCellText=oJTable.GetCellData(iCounter, sColName)
If instr(sText, sGetCellText)>0 Then
bChkText=TRUE
GetRowWithCellText=iCounter
End If
Next
ReportingFunction bChkText, "Row with desired text"
End Function
RegisterUserFunc "JavaTable", "GetRowWithCellText", "GetRowWithCellText", TRUE
该函数已正确注册,并且在Java表的可用函数列表中得到了它。 但是,当尝试在我的应用程序中将该函数应用于JavaTable时:
JTable.GetRowWithCellText msg.users.list.table.header.user , LOGIN
我收到以下错误:
Object required: 'msg'
Line (122): "JTable.GetRowWithCellText msg.users.list.table.header.user , LOGIN".
请注意,UFT不能对表的cols进行重新分类,因此我手动插入了它的值
从“需要对象”错误看来,“ msg”的值未定义。 msg.users.list.table.header.user
的第一部分引用名为“ msg”的对象。 如果该对象不存在或尚未初始化,则可能会收到该错误。
您可以分解语句以确认错误所在。 更改此声明
JTable.GetRowWithCellText msg.users.list.table.header.user , LOGIN
对于这些陈述
Dim user
Set user = msg.users.list.table.header.user
JTable.GetRowWithCellText user, LOGIN
重新执行时,如果msg
存在问题,则应该在第二行显示错误; 否则,如果确实是函数问题,则会在第三行显示错误。
我使用了列索引而不是列名,并且可以正常工作,我猜有一个特殊字符问题。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.