如果Internet Explorer第一次使用代碼啟動,那么就沒有問題。
如果網站已經登錄到系統中,我得到一個錯誤
。物件不支持...
如果網頁已經登錄,我想跳過這個登錄階段
。我使用的示例代碼
Sub Login()
Dim IE As New InternetExplorer, url As String
Dim Html As HTMLDocument, idCheck As Object
url = "https://abc-site.com/"/span>
With IE
.Visible = True[/span]。
.Navigate2 網址
While .Busy Or .readyState < 4: DoEvents: 補習班
Set Html = .document
結束 有
Set idCheck = Html.querySelector(" .Log In")
If Not idCheck Is Nothing Then
Html.querySelector("[name=userName]").Value = "用戶名"。
Html.querySelector("[name=password]").Value = "密碼"。
Html.querySelector("[type=submit]").Click
While IE.Busy Or IE.readyState < 4: DoEvents: 補上
Else: DoEvents: Wend
End If If
End Sub
用戶名稱
< input id="Content1_UserIDView_txtUserid_UiInput" ng-class="{'ror' : AuthMethod. error}" type="text"/span> class="form-control bb-input bb-username-input ng-pristine ng-scope ng-empty ng-invalid ng-invalid-required ng- touched" placeholder="user ID" autocomplete="off" ng-model="AuthMethod. user" ng-change="AuthMethod.getMethodOnChange(method.input.)" ng-change="AuthMethod.getMethodOnChange(method.input.) id)" ng-disabled="false" ng-if="method. label.text !==' *' && method.input.id。 length > 0" ng-init="AuthMethod. getUser()" tabindex="0"/span> focus-if="" required=" aria-invalid="true">
密碼
< input id="Content_UserIDView_tbxPassword_UiInput" ng-class="{'error' : AuthMethod. error}" type=" password" class="form-control bb-input bb-password-input ng-pristine ng-scope ng-empty ng-invalid ng-invalid-required ng- touched" placeholder="Password"/span> autocomplete="off" ng-model="AuthMethod. pass" ng-change="AuthMethod. getPassOnChange(method.input.id, $event)" ng-disabled="false" ng-if="method.label. text !==' *' && method.input.id.length > 0" ng-init="AuthMethod. getPass()" tabindex="0" focus-if="AuthMethod.authMethodId[0].label.text.length ==0"。 text.length ===0" required="" aria-invalid="true">
登錄按鈕
< a href="#"/span> class="btn-primary bb-binding" ng-disabled="UserIdButton。 shouldDisableButton()" ng-click="! UserIdButton.shouldDisableButton() && UserIdButton.click(UserIdButton.userIdViewBtn.button)。 id)" title=" Log In" disabled=" disabled">
登錄
</a>/span>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
。If . querySelectorAll("#Content1_UserIDView_txtUserid_UiInput").length > 0 Then
'做登錄頁面的事情。
Else
'跳過登錄代碼'跳過登錄代碼
End If
'繼續執行其他代碼....
感謝QHarr,它幫助了我,解決了我的問題。
。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/331278.html
標籤:
