I am new to VBA. I am trying to click on the "GO" search button after I logged in to a secured website.
I tried many ways to click on the button, but I got no luck.
Here is the inspect element.
<button class="button primary pull-right" ng-click="search()" ng-disabled="searchForm.$invalid">
Go <i class="glyphicon glyphicon-chevron-right"></i>
</button>
Here is what I have tried.
Method 1
Set HTMLDoc = HTMLDoc.class("button primary pull-right").document
Set button = HTMLDoc.getElementsByTagName("BUTTON")(0) 'first button
button.Click
For i = 1 To 5
button.Click
DoEvents
Next
Method 2
For Each hyper_link In allhyperlinks
If hyper_link.class = "button primary pull-right" Then
hyper_link.Click
Exit For
End If
Next hyper_link
Method 3
Set allhyperlinks = IE.document.getElementsByTagName("button")
For Each hyper_link In allhyperlinks
If hyper_link.getAttribute("class") = "search" Then
hyper_link.Click
Exit For
End If
Next
Method 4
Dim oHTML_Element As IHTMLElement
Dim oBrowser As InternetExplorer
Dim ie As Variant
For Each oHTML_Element In ie.document.getElementsByName("button")
If oHTML_Element.className = "button primary pull-right" Then
oHTML_Element.Click
End If
Next
Method 5
Set ie = CreateObject("InternetExplorer.Application")
With ie
Do Until .readyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:15"))
ie.document.getElementsByClassName("button primary pull-right").Click
Application.Wait (Now + TimeValue("0:00:1"))
End With
Method 6
Set ie = CreateObject("InternetExplorer.Application")
ie.document.getElementByClassName("button primary pull-right")(0).Click
Any help would be greatly appreciated.
Thank you!