I have form which I would like to open IE window, navigate to specific web page, input some data, click the submit button and capture results.
I have been stuck at clicking the submit button part for days and search multiple forums for answer but no luck. The reason I believe is because it's not a true button and does not have a name tag or id I can reference
The site that I am accessing is http://trulos.com/mileage/
inspect code from chrome for the button
Calculate Mileage
I can input the Origin address and Destination address but just can not figure out how to click the "Calculate mileage button.
Sample code I am working with
Dim frominput As String
Dim toinput As String
frominput = "Stockton, CA"
toinput = "Lubbock, TX"
Dim ele As Object
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
IE.navigate "http://trulos.com/mileage/"
IE.Visible = True
While IE.busy
DoEvents
Wend
Pause (2)
IE.Document.all("from").Value = frominput
IE.Document.all("to").Value = toinput
'IE.Document.Forms(0).submit
'IE.Document.all("button:Calculate Mileage").Click
'IE.Document.all("btnG").Click
'IE.Document.getElementsByTagName("button")(0).Click
'Set ele = IE.Document.getElementsByClassName("Panel-Body")(0)
'MsgBox ele.classname
'<button type="button" onclick="get_addresses();" class="btn btn-default"> Calculate Mileage</button>
'MsgBox IE.Document.body.innertext
'MsgBox IE.Document.getElementsByClassName("btn btn-default")
'Set the_input_elements = IE.Document.getelementsbytagname("input")
'For Each input_element In the_input_elements
'If input_element.getattribute("class") = "btn btn-default" Then
' input_element.Click
' Exit For
'End If
'Next input_element
'Set tags = IE.Document.getElementsByTagName("button")
Set tags = IE.Document.getElementsByClassName("btn btn-default")
For Each tagx In tags
If tagx.innertext = "submit" Then
tagx.Click
Exit For
End If
MsgBox tagx.innertext
Next