Jump to content

Unable to click an IE button


dustintt
 Share

Recommended Posts

Hi,

I have been trying out AutoIT for a few weeks and now I have come accross a case where I need some assistance:

I can log into my router and navigate to the relevent page, but I cannot click the Backup Settings button.

If I Tab around the page, sometimes it works and sometimes the Tab ends up in a different location, so I would like to use an alternative method.

I have tried the AutoIT Window Info tool and even when I used the Advanced Class name it still did not work.

Here is the code that I am now trying to use instead of Tabing around:

Code:

$oIE = _IECreate("http://routerurl.html")
$oButton = _IEGetObjByName($oIE, "Backup Settings")
_IEAction($oButton, "click")

Page HTML:

<BLOCKQUOTE>

<FORM><B>Settings -- Backup Settings</B><BR><BR>Backup DSL Router configurations. You may save your router configurations to a file on your PC.<BR><BR><BR>

<P align=center><INPUT onclick=backupClick() value="Backup Settings" type=button></P></FORM></BLOCKQUOTE>

Console Error:

--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Backup Settings, Index: 0)

--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType

Can someone help me click this button and also tell me what I am doing wrong?

Thanks in advance,

DR

Link to comment
Share on other sites

_IEGetObjByName gets an object by name. The object it tries to get must have the name attribute defined. For example:

<a name="lolwut">

You can then get it with _IEGetObjByName($oIE, "lolwut") and you have your object.

Thanks Manadar.

That explains what I am doing wrong.

Any suggestions for clicking the button?

Link to comment
Share on other sites

Check out this example:

It will click on every "input" on that page.

#include <IE.au3>
$oIE = _IECreate("http://routerurl.html")
$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
   _IEAcion($oInput,"click")
Next
Link to comment
Share on other sites

Check out this example:

It will click on every "input" on that page.

#include <IE.au3>
$oIE = _IECreate("http://routerurl.html")
$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
   _IEAcion($oInput,"click")
Next

Thanks Juvigy,

That worked as well, but also gave the IE script protection popup that Manadar's solution did. If there is no other way to click the button without getting the script popup then I will try to work around it.

DR

Link to comment
Share on other sites

If this is just for yourself (I see routerurl and invalid HTML) you can adjust the security settings of Internet Explorer. You can add your router website as an exception, so it has more priviledges.

Manadar,

Actually I want to give this out after making an exe.

DR

Link to comment
Share on other sites

If this is just for yourself (I see routerurl and invalid HTML) you can adjust the security settings of Internet Explorer. You can add your router website as an exception, so it has more priviledges.

Manadar,

If I revert to using my Tabing solution which Tabs 8 times before it reaches the button, any idea why sometimes it will correctly stop on the button and sometimes it will end up on some other control?

DR

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