Sign in to follow this  
Followers 0
flmbray

IE.au3: Can I get a specific object using an XPath?

7 posts in this topic

I have an object on a web page that I need to click. It isn't a link and it doesn't have an id. It is a TD with a class on it, but so do many other TDs (with the same class). I have a specific XPath to the object: /html/body/form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2] (I got this from Firebug in Firefox.) How can I use IE.au3 to obtain and click this specific object?

TIA!

Share this post


Link to post
Share on other sites



I have an object on a web page that I need to click. It isn't a link and it doesn't have an id. It is a TD with a class on it, but so do many other TDs (with the same class). I have a specific XPath to the object: /html/body/form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2] (I got this from Firebug in Firefox.) How can I use IE.au3 to obtain and click this specific object?

TIA!

I don't know if that with IE works but with the FF.au3 you can do this:

_FFClick( _FFXpath("//form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2]", "", 9 ) )

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

XPath is only available in IE via the MSXML object and not the InternetExplorer document object, so it is not so convenient.

Your "selector" (/html/body/form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2]) should work this way:

$oElement = $oIE.document.body _
    .getElementsByTagname("form").item(0) _
    .getElementsByTagname("div").item(2) _
    .getElementsByTagname("div").item(3) _
    .getElementsByTagname("div").item(2) _
    .getElementsByTagname("table").item(0) _
    .getElementsByTagname("tbody").item(0) _
    .getElementsByTagname("tr").item(0) _
    .getElementsByTagname("td").item(2)

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

_FFClick( _FFXpath("//form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2]", "", 9 ) )
:( i think you trying to rape mediafire. :)

Share this post


Link to post
Share on other sites

XPath is only available in IE via the MSXML object and not the InternetExplorer document object, so it is not so convenient.

Your "selector" (/html/body/form/div[2]/div[3]/div[3]/div[2]/table/tbody/tr/td[2]) should work this way:

$oElement = $oIE.document.body _
    .getElementsByTagname("form").item(0) _
    .getElementsByTagname("div").item(2) _
    .getElementsByTagname("div").item(3) _
    .getElementsByTagname("div").item(2) _
    .getElementsByTagname("table").item(0) _
    .getElementsByTagname("tbody").item(0) _
    .getElementsByTagname("tr").item(0) _
    .getElementsByTagname("td").item(2)

Dale

Oooh. Very cool syntax, Dale. Thanks for that demo, as I have a specific application for it at work!

:(


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

Share this post


Link to post
Share on other sites

What if I have an id or class in the middle? how this should work?

//*[@id="details"]/div[2]/div[2]/div/div[1]/h3/span/span[1]

.getElementsByTagname("id?").item(0) _

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'm working on one ;) it's in my signature. Right now, there are several conditions...and i just had a breakthrough in one

unfortunatly, with your xpath provided, i can already point out, i have not made use of the '*' or specifiying the 2nd such div '[2]'

Edited by jdelaney

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.

Share this post


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
Sign in to follow this  
Followers 0