如何修复“ VBscript”中“对象连接从其客户端丢失”的错误?

时间:2019-02-11 13:44:04

标签: vbscript

我尝试自动登录网站的代码。但是它不断抛出

  

对象与客户端的连接断开

Dim IE
set IE = WScript.CreateObject("InternetExplorer.Application")
IE.Visible = true

Call IE.navigate("http://finrpa:8080/controlroom/")

Do While IE.ReadyState <> 4
    WScript.Sleep 10
Loop

IE.Document.all.username-inputEl.Value = "parthiban.nadar@thirdware.com"
IE.Document.all.password-inputEl.Value = "Thirdw@re1"

Call IE.Document.all.gaia_loginform.submit

Set IE = Nothing

1 个答案:

答案 0 :(得分:0)

抛出异常的那一行? 我发现脚本至少有一个问题。因为控件名称包含破折号,所以它们应该是字符串。所以,而不是

IE.Document.all.username-inputEl.Value = "parthiban.nadar@thirdware.com"
IE.Document.all.password-inputEl.Value = "Thirdw@re1"

应该是

IE.Document.getElementById("username-inputEl").Value = "parthiban.nadar@thirdware.com"
IE.Document.getElementById("password-inputEl").Value = "Thirdw@re1"