2016-02-19 93 views
0

我有一個小的VBScript打開一個網頁並輸入我的登錄憑證。但是,我總是遇到錯誤,不知道如何解決。找不到我的腳本錯誤

Call Main 

Function Main 
    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") 
    IE.Visible = True 
    IE.Navigate "https://x10hosting.com/sso/login" 
    Wait IE 
    With IE.Document 
     .getElementByID("identifier").value = "[email protected]" 
     .getElementByID("password").value = "FAKEPASS" 
     .getElementsByName("button button-rounded button-primary")(0).Submit 
    End With 
End Function 

Sub Wait(IE) 
    Do 
    WScript.Sleep 500 
    Loop While IE.ReadyState < 4 And IE.Busy 
End Sub 

的錯誤是:

line: 11 
char: 9 
Error: Object required: 'getElementsByName(...)(...)' 
code: 800A01A8 
sources: Microsoft VBScript runtime error
+0

@AnsgarWiechers請看帖子。我編輯了 –

回答

0
With IE.Document 
    .getElementByID("identifier").value = "[email protected]" 
    .getElementByID("password").value = "FAKEPASS" 
    .getElementsByName("button button-rounded button-primary")(0).Submit 
End With 

難道因爲你使用的是getElementsByName錯了嗎? getElementsByName查找具有該名稱的屬性,但似乎您使用了類名。

Check this for getElementsByName

您需要使用getElementsByClassName方法。

Check this for getElementsByClassName