Jump to content

How would I click this button on webpage ?


Recommended Posts

here's the html code snippet which produces a couple buttons I need to click in my script.

<div align="center">
<button onclick="_submit(); return false;">Calculate</button>&nbsp;
<button onclick="_clear(); return false;">Clear</button>
</div>

I'm trying to have my script click on either button but having trouble.

I've tried:

$oSubmit = _IEGetObjByName ($oIE, "Calculate")

_IEAction ($oSubmit, "click")

gives a warning:

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Calculate, Index: 0)--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

Edited by Valhalla1
Link to comment
Share on other sites

here's the html code snippet which produces a couple buttons I need to click in my script.

<div align="center">
<button onclick="_submit(); return false;">Calculate</button>&nbsp;
<button onclick="_clear(); return false;">Clear</button>
</div>

I'm trying to have my script click on either button but having trouble.

I've tried:

$oSubmit = _IEGetObjByName ($oIE, "Calculate")

_IEAction ($oSubmit, "click")

gives a warning:

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Calculate, Index: 0)--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

The text in the button is "innertext", not "name". There isn't a function to find it by innertext, so you get the collection of "button" tags and loop through them:
$colButtons = _IETagNameGetCollection($oForm, "button")
$iButtonCnt = @extended
ConsoleWrite("Debug: There are " & $iButtonCnt & " buttons in the collection." & @LF)
Global $oCalc, $oClear
For $oButton In $colButtons
    If $oButton.innertext = "Calculate" Then $oCalc = $oButton
    If $oButton.innertext = "Clear" Then $oClear = $oButton
Next
_IEAction($oCalc, "click")
_IEAction($oClear, "click")

Note you need to have already drilled down to the Form, Frame, iFrame, whatever already.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...