scttech1967

AutoIT not finding button on web page (no ID)

7 posts in this topic

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



Since it's the only button in the form, you could try _IEFormSubmit()

Share this post


Link to post
Share on other sites

Try 

if $oButton.outertext = "file" then


Share this post


Link to post
Share on other sites
15 minutes ago, BigDaddyO said:

Try 

if $oButton.outertext = "file" then

Think you meant innertext, right?

Share this post


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

 


Share this post


Link to post
Share on other sites
33 minutes ago, BigDaddyO said:

nope, I meant outertext

Ok... looks like they return the same value in this case. ;)

Share this post


Link to post
Share on other sites

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