正在填充用户名,但该按钮仅在我用鼠标实际点击用户名字段后才能工作....
HTMLDoc.getElementById("loginForm-email").Focus
HTMLDoc.getElementById("loginForm-email").Click
HTMLDoc.getElementById("loginForm-email").Value = "A Username"
HTMLDoc.getElementById("loginForm-next").Focus
HTMLDoc.getElementById("loginForm-next").Click
网站登录页面https://www.britishgas.co.uk/identity/
HTML如下
<!---->
<div>
<div class="container login index mt6">
<!---->
<!---->
<h1 class="h2 text-center">Access account
</h1>
<div id="ember427" class="ember-view">
<form id="ember444" class="form-behaviour-default text-center no-success form-behaviour-default text-center unsubmitted ember-view">
<div id="ember471" class="scroll-anchor scroll-anchorerror ember-view">
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4 col-xs-12">
<div id="ember474" class="has-feedback form-group has-error pristine untouched ember-view">
<label for="loginForm-email">Email address</label>
<input name="username" autocapitalize="none" id="loginForm-email" class="form-control text-center ember-text-field ember-view" type="text">
<span aria-hidden="true" class="glyphicon glyphicon-ok form-control-feedback">
</span>
<span aria-hidden="true" class="glyphicon glyphicon-remove form-control-feedback">
</span>
<p id="loginForm-email-error" class="form-control-error">
<i class="fa fa-exclamation-triangle"></i> We need an email address from you
</p>
</div>
</div>
</div>
<div class="form-group text-center">
<button style="touch-action: manipulation; -ms-touch-action: manipulation; cursor: pointer;" type="submit" id="loginForm-next" class="bg-button btn btn-primary ember-view">
<span aria-hidden="true" class="bg-button-icon fa fa-angle-right">
</span> Next
</button>
</div>
</form>
</div>
<div class="text-center mb4">
<a style="touch-action: manipulation; -ms-touch-action: manipulation; cursor: pointer;" href="#/forgotten-details/forgotten-email" id="ember488" class="btn btn-tertiary ember-view">
<span aria-hidden="true" class="fa fa-angle-right">
</span>I've forgotten my email
</a>
</div>
</div>
HTML的结尾
以下适用于我,虽然使用虚构信息然后提示更多信息:
Option Explicit
Public Sub GetInfo()
Dim IE As New InternetExplorer
With IE
.Visible = True
.navigate "https://www.britishgas.co.uk/identity/"
While .Busy Or .readyState < 4: DoEvents: Wend
With .document.getElementById("loginForm-email")
.Focus
.Value = "[email protected]"
End With
Application.Wait Now + TimeSerial(0, 0, 1)
With .document.getElementById("loginForm-next")
.Focus
.Click
End With
'.Quit
End With
End Sub