[英]Object required UFT/VBS
嗨,我是uft和vbs的新手,我想做的是從網絡元素中獲取內部文本並從中獲取帳號,我將字符串拆分成一個數組,並知道要在文本中選擇的單詞隨機生成的帳號。 我的問題是我在if語句中的“應用程序”上得到一個erro0r,其中說:
所需對象:“應用程序”行(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
將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的更多信息
請更改此行
If Arry(i).ToString <> ("Application" or "Number") then
至
If (Arry(i).ToString <> "Application") Or (Arry(i).ToString <> "Number") then
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.