Jump to content

AutoIT not finding button on web page (no ID)


 Share

Recommended Posts

How do I click on the "Find" button on a web page that doesn't have an ID? See code & html below. Any help appreciated.

; code doesn't find & click the button
$oButtons = _IEFormElementGetCollection($oIE, "button")
For $oButton in $oButtons
  If String($oButton.value) = "Find" Then
     _IEAction($oButton, "click")
  EndIf
Next


Code from the web page
<form id="latlongform">
<label for="gadres">Place Name</label>
<input id="gadres" type="text" placeholder="Type a place name" class="width70" required  />
<button title="Find Lat &amp; Long" class="button">Find</button><br />
<small>Add the country code for better results. Ex: London, UK</small>
</form>

Link to comment
Share on other sites

nope, I meant outertext.  Though looking closer, the _IEFormElementGetCollection in the OP isn't being use properly.

 

Typically I use _IETagNameGetCollection when working with web pages.  Not sure if this will work as is, but I'd do something like

$oTAGs = _IETagNameGetCollection($oIE, "button")
For $oTag in $oTAGs
    If $oTAG.className = "button" Then
        If $oTAG.outertext = "Find" Then
            _IEAction($oTAG, "click")
            ExitLoop
        EndIf
    EndIf
Next

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...