2016-02-19 115 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