我需要登录网站。 每次我使用VBA进行凭证时,在点击事件之后,它都说密码不正确。
如果我通过VBA插入凭证,如果我手动取消用户名的一个字母,我会重写它,如果我手动取消密码的一个字母并重写密码,那么在我用VBA发送点击事件后,它就可以了
这是什么原因? Shound我使用kinda keypress事件插入凭证?这是正确的语法?
感谢
请参阅下面的HTML代码和我在VBA中写的内容
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "sss.html"
Do Until .ReadyState = 4
DoEvents
Loop
.Document.all.Item("login").Value = "username"
.Document.all.Item("password").Value = "password"
Set elems = ie.Document.getElementsByTagName("button")
For Each e In elems
If (e.innerHTML = "Confirm") Then
e.Click
Exit For
End If
Next e
<input type="text" ng-model="login" class="form-control ng-pristine ng-valid ng-touched" id="login" placeholder="Enter login (email)">
<input type="password" ng-model="password" class="form-control ng-pristine ng-valid ng-touched" id="password" placeholder="Password">
<button class="btn btn-default" ng-click="authenticate()" notranslate="">Confirm</button>
答案 0 :(得分:0)
这个网站希望您实际输入您的用户名/密码并实际按下&#34;确认&#34;按钮,您可以使用SendKeys
因此,不要为按钮元素设置value
和循环,而是使用以下代码:
.Document.all.Item("login").focus
SendKeys "username", True
.Document.all.Item("password").focus
SendKeys "password", True
SendKeys "{TAB}", True
SendKeys "~", True
希望这会有所帮助。