If Internet Explorer starts for the first time with code then there is no problem.
If the web site is already logged in the system, I get an error
Object does not support...
I want to skip this login stage if the webpage is already logged-in.
The sample code I used
Sub Login()
Dim IE As New InternetExplorer, url As String
Dim Html As HTMLDocument, idCheck As Object
url = "https://abc-site.com/"
With IE
.Visible = True
.Navigate2 url
While .Busy Or .readyState < 4: DoEvents: Wend
Set Html = .document
End With
Set idCheck = Html.querySelector(".Log In")
If Not idCheck Is Nothing Then
Html.querySelector("[name=userName]").Value = "username"
Html.querySelector("[name=password]").Value = "password"
Html.querySelector("[type=submit]").Click
While IE.Busy Or IE.readyState < 4: DoEvents: Wend
Else
End If
End Sub
USER NAME
<input id="Content1_UserIDView_txtUserid_UiInput" ng-class="{'error' : AuthMethod.error}" type="text" 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.id)" ng-disabled="false" ng-if="method.label.text !== ' *' && method.input.id.length > 0" ng-init="AuthMethod.getUser()" tabindex="0" focus-if="" required="" aria-invalid="true">
PASSWORD
<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" 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" required="" aria-invalid="true">
Login Button
<a href="#" class="btn-primary bb-binding" ng-disabled="UserIdButton.shouldDisableButton()" ng-click="!UserIdButton.shouldDisableButton() && UserIdButton.click(UserIdButton.userIdViewBtn.button.id)" title=" Log In" disabled="disabled">
Log In
</a>
Found solution for the above query from the Link
If .querySelectorAll("#Content1_UserIDView_txtUserid_UiInput").length > 0 Then
'do login page stuff
Else
'Skip login code
End If
'proceed with the other code....
Thanks QHarr it helped me and resolved my problem.