Jump to content
Sign in to follow this  
Vishal85

IE Library - _IEGetObjBy functions

Recommended Posts

Vishal85

_IEGetObjById and _IEGetObjByName functions use variable of an InternetExplorer.Application, Window or Frame object as reference to find any dom element.

Is it possible to use a dom element instead of InternetExplorer.Application, Window or Frame to find target dom element instead the dom element. This will help in finding elements using a parent child relationship where duplicate target dom elements exists on the HTML page.

Other automation tools like WebDriver do have this feature. It would be great to have something like this in AutoIt. I love the way AutoIt works!!!!! Especially the IE UDF. Cool stuff from DALE and other developers.

Ex - i would like to do something like this,

$oIE = _IEAttach("Title")

$oParentObject = _IEGetObjById($oIE, "Parent Widget or element Id which contains my target widget in its hierarchy below")

$oTargetObject = _IEGetObjById(oParentObject , "Id of widget i would like to find and do some action")

_IEAction($oTargetObject, "click")

This will help in situations where there are widgets with duplicate ids on the page....Ex - 2 Add buttons with same id on the same page.....One add button to add a CAR...another Add button to add a Vehicle. In this case i cannot click on the exact Add button i want just with the Add button id. i will need reference of their immediate parent object to uniquely identify them.

Share this post


Link to post
Share on other sites
DaleHohm

In fact, _IEGetObjByName DOES work that way - it is an oversight in the docs not to specify it.

_IEGetObjByID does NOT work that way because it is illegal to have two objects with the same ID on a page. How the DOM handles such a situation is inconsistent and you may want to use other methods to select such objects (such as _IETagnameGetCollection).

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

Share this post


Link to post
Share on other sites
Vishal85

Thanks for the calrification Dale! I used the _IETagnameGetCollection function finally!

One quick question. We often do something like oObject.title or oObject.id or oObject.name etc...... is there a way i can paremetrize the .id, .name, .title....

I would like to do something like

$sAttribValue = oObject.$sAttribute

OR

$sAttribValue = oObject & "." & $sAttribute

Here $sAttribute = id or name or title or innerHTML etc....

I tried both ways but didnt work.

Share this post


Link to post
Share on other sites
DaleHohm

You can use Execute like this:

$oItems = Execute("$o_object.elements('" & $s_Name & "')")

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

Share this post


Link to post
Share on other sites
Vishal85

I will try that....thanks for your help!

Plesae let me know if can help contribute to the IE UDF. I have worked quite a lot with the IE UDF and have gone through you code.

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  

  • Similar Content

    • TLAM
      By TLAM
      Hello,
      I am working on an autoIT script for CyberArk which is running Internet Explorer and connecting the user to a web application.
      For an unknown reason (I cannot explain why), IE has some trouble to start, only after a long disconnecting period (morning or after lunch). If he tries again, no problem, IE starts.
      I open a case with CyberArk but I am also searching a workaround, I thought to kill the process directly, or set a timeout with _IELoadWait but the process is not really created..

      May do you have any ideas for helping me ?

      Thanks in advance
       
    • IAMK
      By IAMK
      If you press the "Login" button in the top-left of https://www.showroom-live.com/, it creates a popup in which you press "Login with Twitter ID", which then opens a new window with an "Authorize app" button.
      None of these 3 buttons have a Name or ID, so how do I click on them, because _IEGetObjByName / _IEGetObjByID will not work.
      Here are the sources of the 3 buttons:
      ;Login button. ;<a onclick="showLoginDialog();" href="javascript:void(0);">Login</a> ;Twitter button (Note that I am already signed into Twitter and just need to Authorize it). ;<a class="btn-twitter btn-sky-blue submit fs-b5" onclick="window.open('/social/twitter/redirect_authorize_url?login=1&from_browser=1', 'twitter', 'width=500,height=400,menubar=yes,status=yes,scrollbars=yes');" href="javascript:void(0);">Login with Twitter ID</a> ;Popup window appears. ;<input class="submit button selected" id="allow" type="submit" value="Authorize app"> I have also tried:
      Local $oLinks = _IETagNameGetCollection($ie, "a") For $oLink In $oLinks If $oLink.InnerText = "showLoginDialog()" Then _IEAction($oLink, "Click") ExitLoop EndIf Next I've even tried adding "showLoginDialog()" and "javascript:void(0)" to the end of the URL, but as expected, that wouldn't work either.
      My goal is something like this:
      #include <IE.au3> Local $ie = _IECreate("https://www.showroom-live.com/onlive") _IELoadWait($ie) Local $originalHandle = $ie ;===Functions========================================================== Func login() ;Source: <a onclick="showLoginDialog();" href="javascript:void(0);">Login</a> _IEAction(ABOVESOURCE, "Click") ;Source: <a class="btn-twitter btn-sky-blue submit fs-b5" onclick="window.open('/social/twitter/redirect_authorize_url?login=1&amp;from_browser=1', 'twitter', 'width=500,height=400,menubar=yes,status=yes,scrollbars=yes');" href="javascript:void(0);">Login with Twitter ID</a> _IEAction(ABOVESOURCE, "Click") ;New window appears for Twitter sign in, but the URL is locked. ;Source: <input class="submit button selected" id="allow" type="submit" value="Authorize app"> _IEAttach($ie, ABOVEHANDLE) ;How do I get the handle of the new window from above? _IEAction(ABOVESOURCE, "Click") _IEAttach($ie, $originalHandle) EndFunc ;====================================================================== ;===Code=============================================================== login() ;======================================================================  
      Thank you in advance.
    • Seminko
      By Seminko
      Wrote a script that grabs all of the IP addresses from Netflix's IP log, checks the IPs and returns suspicious activity.
      Everything works as it should but only when _IECreate is set to visible. When visible is set to false, it fails to login for some reason.
      Any ideas what might cause it and/or how to circumvent that?
    • nooneclose
      By nooneclose
      Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
      HTML Code: 
      <img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
      ;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction($nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue # 
      (For those wondering, I am allowed to send images just not the URL.) 
      As always any help would be appreciated. 

    • slyx
      By slyx
      When I use _IEGetObjById to get form obj, it failed. My code works two month ago, but now there is some update in the website. The first page is OK wiht _IEGetObjById, but when goes to the second page, _IEGetObjById get error.
      The error is:
      IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch
      Any idea will be appreciated!
×