简而言之,我试图自动执行一项任务以登录并验证登录是否成功。
$username = "XXXX"
$password = "XXXXXXXX"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$true
$ie.navigate("https://com/login")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("user_email").value= "$username"
$ie.document.getElementById("user_password").value = "$password"
$ie.document.getElementById("Loginform").submit()
start-sleep 20
$ie.Document.body
它抛出错误
Exception from HRESULT: 0x800A01B6
+ $ie.document.getElementById("user_email").value= "$username"
At line:8 char:1
+ $ie.document.getElementById("user_password").value = "$password"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], NotSupportedException
+ FullyQualifiedErrorId : System.NotSupportedException
Exception from HRESULT: 0x800A01B6
At line:9 char:1
我可以确认登录框的HTML ID是user_email和user_password