Jump to content
Sign in to follow this  

How do you access DOM items by class?

Recommended Posts


Can someone help with accessing items with id in bold below??

<BODY><FORM name="myform" action="">

<TABLE class="main" cellSpacing="0" cellPadding="0" width="820">

<TBODY><TR><TD vAlign="top" align="left" colSpan="2">

<TABLE class="content" id="controls" cellSpacing="0" cellPadding="0">

<TBODY><TR vAlign="top"><TD><TABLE class="menu" style="MARGIN-TOP: 11px">

<TBODY><TR><TD id="zoomin_button" style="PADDING-LEFT: 20px; PADDING-BOTTOM: 2px">

<UL id="buttonh"><LI class="zoomin">

<A onmouseup="return stopZoomIn();"

class="zoomin" onmousedown="return startZoomIn();"

onmouseover="window.status='zoom in'; return true;"

onclick="return false" onmouseout="window.status=''; stopThreads()" href="">&nbsp;

</A> </LI></UL></TD></TR></TBODY></TABLE></TD></TR></TBODY>


Case1: --> doesn't work

$obt1 = _IEGetObjById($oIE, "zoomin_button")

_IEAction($obt1, "focus")



Case2: ---> Works but there are other buttons with the same id (see the html below)

For $i = 1 to 5 Step 1

$obt1 = _IEGetObjById($oIE, "buttonh")

_IEAction($obt1, "focus")






<BODY><FORM name="myform" action=""><TABLE class="main" cellSpacing="0" cellPadding="0" width="820"><TBODY><TR><TD vAlign="top" align="left" colSpan="2"><TABLE class="content" id="controls" cellSpacing="0" cellPadding="0"><TBODY><TR vAlign="top"><TD><TABLE class="menu" style="MARGIN-TOP: 11px"><TBODY><TR><TD id="save_button" style="PADDING-BOTTOM: 2px"><UL id="buttonh"><LI class="menu"> <A class="menu" onmouseover='window.status="save image to a file"; return true;' style="PADDING-RIGHT: 10px; PADDING-LEFT: 5px" onclick="return saveAs();" onmouseout='window.status="";' href="">SNAPSHOT</A> </LI></UL></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>


Share this post

Link to post
Share on other sites

Some of your attempts don't work because _IEAction focus does not move the mouse pointer... so your mouse cllicks are not where you expect them to be.

To answer your specific question:

$oElements = _IETagnameGetCollection$oIE, "li")
For $oElement in $oElements
    If String($oElement.className) = "zoomin" Then
        ConsoleWrite("I found it - it is $oElement" & @CR)

Now, use that information along with the 2nd example for _IEPropertyGet that shows you how to find the coordinates of an element and move the mouse there and see if the rest of what you are trying to do works...


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

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.