对象需要UFT / VBS

时间:2017-09-11 11:40:26

标签: vbscript

嗨,我是uft和vbs的新手,我想要做的是从webelement获取innertext并从中获取帐号我将字符串拆分成一个数组并知道我想要的文本中会出现什么字选择随机生成的帐号。我的问题是我得到了一个错误的应用"应用"在if语句中说:

所需对象:'应用程序' 线(60):"如果Arry(i).ToString<> ("申请"或"号码")然后"。

我不知道如何继续这样做,所以任何帮助都会被批评。

App_Num = oPage_Account.WebElement("Application 
Number").GetROProperty("innertext")
sDelimiter = " "
Arry = Split(App_Num, sDelimiter) 'Split the string by the spaces
iLoop = UBound(Arry) 'Find the size of the array
For i = 0 to iLoop ' loop to see if accepted
   If Arry(i).ToString <> ("Application" or "Number") Then
   App_Num = Arry(i)
   Reporter.ReportEvent micDone, "Account Num", "Account Number is Assigned" 
   End If
Next

2 个答案:

答案 0 :(得分:0)

将If条件重写为:

If strComp(Arry(i),"Application")<>0 or strComp(Arry(i),"Number")<>0 then
    ' your code...
    '...
    '...
End If

或者只是删除toString()(如下所示),因为Arry(i)不是一个对象,因此你得到了Object Required错误。

 If Arry(i)<>"Application" or Arry(i)<>"Number" then
    ' your code...
    '...
    '...
End If

我会推荐第一种方法。

有关StrComp

的更多信息

答案 1 :(得分:-2)

请更改此行

If Arry(i).ToString <> ("Application" or "Number") then

If (Arry(i).ToString <> "Application") Or (Arry(i).ToString <> "Number") then