Jump to content
scttech1967

AutoIT not finding button on web page (no ID)

Recommended Posts

scttech1967

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>

Share this post


Link to post
Share on other sites
BigDaddyO

Try 

if $oButton.outertext = "file" then


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites
BigDaddyO

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

 


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites
scttech1967

Thanks @BigDaddyO - your suggestion answered my question & made my day!!

Share this post


Link to post
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

×