Jump to content

Click on a website button that doesn't have a name or an id

Recommended Posts


I have tried hard to find the anwser, but haven't found anything that works.

I want to click on the button "Hae", but I can't use form submit, since this isn't the submit button in that form. And the button doesn't have a name or an id.

I can get to the editboxes just fine.

Website source:

    <label for="">Piiriväli</label>
    <input type="text" name="routeNumberFrom" value="" class="route" />
    <input type="text" name="routeNumberTo" value="" class="route" />
    <input type="button" class="button" value="Hae" onclick="submitAction('addRouteInterval');"/>

Code I have so far:

#include <IE.au3>

Opt("SendCapslockMode", 0) ;1=store and restore, 0=don't
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

if MsgBox ( 1, "Jatketaanko", "Ennen kuin jatkat, avaa selain DI sivustolle, tulosta e-jakokirja kohtaan. Tyhjennä mahdolliset piiritiedot. Paina tämän jälkeen OK") = 1 Then

Local $hWin = WinGetHandle("Ejakokirjan tulostus", "") ; DI window

If IsHWnd($hWin) Then

  Local $o_IE = _IEAttach("Ejakokirjan tulostus")

        ConsoleWrite("Ejakokirjan tulostus window handle: $hWin = " & $hWin & @LF)

        ControlFocus($hWin, "", $hWin)

  Local $o_PiiriForm = _IEFormGetObjByName ($o_IE, "printableEbookForm") ; Form name

  Local $o_PiiriFrom = _IEFormElementGetObjByName ($o_PiiriForm, "routeNumberFrom") ; Editbox name

  _IEFormElementSetValue ($o_PiiriFrom, "1022001")

  Local $o_PiiriTo = _IEFormElementGetObjByName ($o_PiiriForm, "routeNumberTo") ; Editbox name

  _IEFormElementSetValue ($o_PiiriTo, "1022009")

  ; Click HAE

        ConsoleWrite("Debug: Error, failed to get control handle for Ejakokirjan tulostus window." & @LF)
Link to post
Share on other sites


It looks like you could just call the Javascript function 'submitAction' directly.


or you can loop over all input elements and match the value.

Local $oInput, $oInputs = _IETagNameGetCollection($o_IE, 'input', -1)
For $oInput In $oInputs
    If $oInput.value == 'Hae' Then
        _IEAction($oInput, "click")
Edited by Robjong
Link to post
Share on other sites
  • 3 weeks later...


Sorry for the late answer, have been busy :oops:

@Sleepydvdr, I can't provide a direct link since the site is behind password protection.

@Robjong, fantastic ! The direct call to the javascript was exactly what I have been looking for. Didn't stumble upon that one anywhere.

Thank you for your help.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...