【发布时间】:2019-06-11 03:51:31
【问题描述】:
我正在编写用于登录表单的脚本,并填写一堆“注册”信息并点击提交。
到目前为止,我已经设法让脚本导航到登录页面,输入用户名,输入密码并单击“登录”。
但是,虽然我通常会使用“While IE.readyState 4 或 IE.Busy: DoEvents: Wend”功能来等待下一页加载,但我遇到了麻烦,因为不幸的是,似乎正在发生的事情是单击登录按钮后,URL 将重定向到大约 2 个临时“加载”页面/URL,然后到达“输入详细信息”页面/URL。
这会导致运行时 13 错误,因为脚本认为页面已经加载,尽管浏览器随后会转到最终/正确的页面。
这里是有问题的代码:
While IE.readyState <> 4 Or IE.Busy: DoEvents: Wend
Set UserN = IE.document.getElementByID("login_username")
UserN.Value = "exampleUser"
Set PassW = IE.document.getElementByID("login_entered_password")
PassW.Value = "ExamplePass"
Set AllHyperLinks = IE.document.getElementsByClassName("label-content")
For Each hyper_link In AllHyperLinks
If hyper_link.innerHTML = "Sign in" Then
hyper_link.Click
Exit For
End If
Next
While IE.readyState <> 4 Or IE.Busy: DoEvents: Wend
Set Fname = IE.document.getElementByID("firstname")
Fname.Value = "John"
End Sub
基本上脚本加载页面>输入用户名>输入密码>点击登录>应该等到最终网址加载>在名字字段中输入名字(在这个工作之后我会写剩下的用于输入详细信息的脚本。
任何和所有的帮助都会很棒! 谢谢大家
【问题讨论】: