Jump to content

Click a button with no ID or Name


Recommended Posts

I need to fire the onclick event for a link but I have no way to identify the object.

<div id="button">
     <a href="" onclick="some_javascript_here">
          <img alt="Add Account" src="images/add_account_button_blue.jpg">
     </a>
</div>

As you can see, I can identify the parent element in the DOM (id="button") but I can't find a way to use that information to target the daughter <a> tag.

Any ideas?

Link to comment
Share on other sites

$oCol = $oDiv.childnodes

Then loop through like:

For $oTag in $oCol

_ieaction($oTag, "Click")

Next

you will need logic if there is more than one child node, inside the loop

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Once you have a reference to the div, you should be able to do the following:

$oElement = _IETagNameGetCollection($oDiv, "A", 0)

Fantastic! Worked like a charm.

Jdelaney - Your solution worked as well and I like that it can be used in boader application although DanP2 solution was sufficiant for this specific issue. Thanks for showing me the childnodes code. Crawling the DOM that way will come in handy at some point!

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