Jump to content

Get IE object by the html 'XPath'


Recommended Posts

...

<div class="btn">

<input type="button" onclick="fnCheckAcess();" value="ENTER" name="">

</div>

...

I have the above, and I'm attempting to find the "button" (it's an input).

This would be easy, if I could use the xpath to find it: //div[@class="btn"]/input

Is there any _IE* function that i may use to grab objects by xpath?

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.
Link to post
Share on other sites

Or (sorry for bump) if you can give me a simple example of using a parent object, to then navigate down to it's children

such as, lets say i have:

<div id="test">

<div class="btn">

<input type="button" onclick="fnCheckAcess();" value="ENTER" name="">

< /div>

,/div.

$oweEHR_Div = _IEGetObjById($oIEBrowser,"test")

$oweEHR_Button = $oweEHR_Div.????

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 post
Share on other sites

thank you w3schools!

code loops through all tags that are <INPUT>, then loops through each of it's attributes, looking for a sepcific attribute/value pair...then set's the object. Now to make a simple function

Local $oElements = _IETagNameAllGetCollection($oweEHR_ParentControl)

For $oElement In $oElements

If $oElement.tagname = "INPUT" Then

$oAttributes = $oElement.attributes

For $oAttribute In $oAttributes

;If $oAttribute.value

If $oAttribute.nodeName = "type" and $oAttribute.nodeValue = "button" Then

$obutton = $oElement

;MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & " attributevalue=" & $oAttribute.nodeValue & " nodetype = " & $oAttribute.nodeType )

endif

Next

EndIf

Next

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.
Link to post
Share on other sites

$oweEHR_Div = _IEGetObjById($oIEBrowser,"test")

$oweEHR_Button = _IETagnameGetCollection($oweEHR_Div, "input", 0)

Dale

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

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