我有一个小的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 = "FAKEEMAIL@my.com"
.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 :(得分:0)
With IE.Document
.getElementByID("identifier").value = "FAKEEMAIL@my.com"
.getElementByID("password").value = "FAKEPASS"
.getElementsByName("button button-rounded button-primary")(0).Submit
End With
可能是因为你使用了getElementsByName错了吗? getElementsByName查找具有该名称的属性,但似乎您使用了类名。
Check this for getElementsByName
您需要使用getElementsByClassName。