VBS website login script - “Object required” error

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

I'm trying to write my first website login script but always getting an error in line 9 position 9 saying: "Object Required: 'getElementByID(...)' 800A01A8. Here's my code for the real working site so that you may have a try:

Call Main  Function Main Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_") IE.Visible = True IE.Navigate "https://www.valuedopinions.com/eng/signin" Wait IE With IE.Document     .getElementByID("tx_voputilities_pi1[email]").value = "my@email.com"     .getElementByID("tx_voputilities_pi1[password]").value = "mypassword"     .getElementByID("tx_voputilities_pi1[sign_in]")(0).Submit End With End Function  Sub Wait(IE) Do WScript.Sleep 500 Loop While IE.ReadyState < 4 And IE.Busy End Sub 

Please help me to write correct working code! It' urgent!

Many thanks beforehand, Sergey

回答1:

Your login form elements have the name rather than id, so you need to use getElementsByName. Also, INPUT elements don't have the Submit method, use click instead:

With IE.Document     .getElementsByName("tx_voputilities_pi1[email]")(0).value = "my@email.com"     .getElementsByName("tx_voputilities_pi1[password]")(0).value = "mypassword"     .getElementsByName("tx_voputilities_pi1[sign_in]")(0).click End With 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!