tsi*_*ilb 4 vbscript automated-tests qtp
我在可重用的操作中有以下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
Run Code Online (Sandbox Code Playgroud)
一切都运行得很好,直到我得到片段底部的循环声明.在那里,QTP给了我一个错误"Object Required"并且拒绝详细说明.
它看起来好像数组是null但不知何故数组有成员?这怎么可能?QTP在谈论什么?
在vbscript数组中没有Count属性,你应该使用UBound
x = split("how now brown cow")
' MsgBox x.Count ' error
MsgBox UBound(x) ' 3
Run Code Online (Sandbox Code Playgroud)
第.Count一个循环的原因是ChildObjects不返回数组,它返回一个COM集合对象.这也是为什么Set在分配时必须使用语句links而不是在分配时使用语句的原因final.
| 归档时间: |
|
| 查看次数: |
7439 次 |
| 最近记录: |