2017-09-11 35 views
0

嗨,我是新來的uft和vbs我想要做的是從webelement中獲取密碼,並從中獲取帳號我將字符串拆分爲一個數組並知道會出現什麼字詞在文本中,我想選擇隨機生成的帳號。我的問題是,我在if語句的「應用程序」中找到erro0r,其中說:對象需要UFT/VBS

Object required:'Application' Line(60):「If Arry(i).ToString <>(」Application「或「號碼」)然後「。

我不知道如何繼續這個,所以任何幫助將appricated。

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 

回答

0

重新寫入如果條件爲:

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

+0

This works great Thx :) – John

+0

歡迎你:) – Gurman

-2

請改變這一行

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

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

更多信息產生相同的錯誤 – John

+0

你如何申報ARRY陣列請檢查一下吧,它可以是問題。 –

+0

檢查這個arry(i).ToString也可能會給出錯誤。 –