[英]QTP: Object Required errors when Object is valid
我在可重用的操作中有以下VBScript:
'Gather links
Browser("1").Navigate "http://InternalWebmail/something/inbox.nsf"
set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
set links = Browser("1").Page("Webmail").ChildObjects(oDesc)
Dim links2
links2 = ""
'Filter out irrelevant links
For i = 0 To links.Count-1
If lcase(trim(links(i).GetROProperty("text"))) = lcase(trim(DataTable("ExpectedFrom", dtGlobalSheet))) Then
links2 = links2 + "," + links(i).GetROProperty("url")
End If
Next
Dim final
final = split(mid(links2,2),",") 'Remove leading comma and split into array
'For each link (i.e. for each E-mail received):
'Effectively giving a reusable action an input parameter, I hope
For i = 0 To final.Count - 1 'error: Object Required
DataTable("url","CheckHeader") = final(i)
RunAction "CheckHeader", oneIteration
Next
一切都運行得很好,直到我得到片段底部的循環聲明。 在那里,QTP給了我一個錯誤“Object Required”並且拒絕詳細說明。
它看起來好像數組是null但不知何故數組有成員? 這怎么可能? QTP在談論什么?
在vbscript數組中沒有Count
屬性,您應該使用UBound
x = split("how now brown cow")
' MsgBox x.Count ' error
MsgBox UBound(x) ' 3
為第一個循環工作的.Count
的原因是ChildObjects
不返回數組,它返回一個COM集合對象。 這也是為什么在分配links
時必須使用Set
語句而不是在分配到final
時使用Set
語句的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.