Jump to content

How to automate this IE button?

Recommended Posts

Dear Colleagues,

Could you please help me with a following button? It changes it's value from 'Cancel' to 'Close' at the end of processing.

Here is the HTML code:

1) Value="Cancel"

<input name="ctl00$bodyPlaceholder$btnCancelarProcessamento" class="button" id="bodyPlaceholder_btnCancelarProcessamento" style="display: none;" onclick="CancelarProcessamento();return false;" type="submit" value="Cancel">

2) Value="Close"

<input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: inline-block;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Close">


And here is my loop:

Sleep ( 3000 )
Func GetButtons()
$oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1)
$i = 0
While $i <> 1
For $oBtn In $oButtons
    If _IEFormElementGetValue($oBtn) = "Close" Then
       $i = 1
        _IEAction($oBtn, "focus")
        _IEAction($oBtn, "click")

What is the problem? The problem is that after Sleep it clicks the button despite it had not changed it's value from "Cancel" to "Close"...


I will really appreciate if you could help me with this!

Link to post
Share on other sites

These appear to be two different buttons. Note the different names and IDs. It's likely that one is being hidden and then other shown at the time that the Close button appears.

Your code could just as easily been written as

$oBtn = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento")
_IEAction($oBtn, "focus")
_IEAction($oBtn, "click")

because that is what happens when you run it. You will need to loop and check the visibility of this button before continuing.

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...