TexasChris Posted December 14, 2012 Share Posted December 14, 2012 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 More sharing options...
jdelaney Posted December 14, 2012 Share Posted December 14, 2012 $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 More sharing options...
Danp2 Posted December 14, 2012 Share Posted December 14, 2012 Once you have a reference to the div, you should be able to do the following: $oElement = _IETagNameGetCollection($oDiv, "A", 0) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TexasChris Posted December 14, 2012 Author Share Posted December 14, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now