[SOLVED] How do you reference an iframe in IE11 with no ID? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
clina1j
Posts: 49
Joined: 22 Apr 2016, 18:39

[SOLVED] How do you reference an iframe in IE11 with no ID?

24 Jan 2018, 19:27

So, I am trying to automate the pushing of a button on a website. The button that I want is within an iframe. So far, so good, I have worked with and around those before. But this one has me flumoxed.
Below is the HTML defining it

Code: Select all

<iframe title="data visualization" src="http://tableau.uhc.com/views/CignaAudits-FinalVersion/CompletedCignaAuditsReport?:size=1903,845&:embed=y&:showVizHome=n&:bootstrapWhenNotified=y&:toolbar=top&%3AopenAuthoringInTopWindow=true&%3AbrowserBackButtonUndo=true&%3AcommentingEnabled=true&%3AreloadOnCustomViewSave=true&%3Asize=1903%2C845&:apiID=host0#1" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen="true" style="width: 1400px; height: 850px; display: block; visibility: visible;" allowtransparency="true"></iframe>
It doesn't have a Name, it doesn't have an ID. All it has is a Title. And, when I try and reference it by that title, Autohotkey freaks and I get a "Member not Found" Error.
How do I grab an I-frame with no name or ID?
Last edited by clina1j on 25 Jan 2018, 12:31, edited 1 time in total.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: How do you reference an ifram in IE11 with no ID?  Topic is solved

24 Jan 2018, 23:48

When there's an element you can't directly reference, get the next closest thing above it in hierarchy, then either pull the frame from instance number or loop through and check its contents. For example, lets say the iframe is inside a <div> tag, which has something searchable (ID, classname, etc.). You can get that with something like divElement:=document.getElementById("DIV_ID") then you can use divElement.getElementsByTagName("iframe")[0], assuming this iframe is the first one found from the previous element (change the 0 accordingly; it's a 0-index linear array). Alternatively, you may combine the commands: iframeElement:=document.getElementById("DIV_ID").getElementsByTagName("iframe")[0] where iframeElement now contains the document element of the iframe, to which you can perform normal document methods on, such as iframeElement.src.

Alternatively, you can omit [0] or any index number to save the HTML live collection and loop through it like so to check for any identifying information if there are still multiple tags:

Code: Select all

loop % iframeElements.length() { ; syntax may be wrong here; length may or may not be available
    if(iframeElements[a_index-1].title="data visualization"){ ; if current-iteration element contains title name
        iframeElement:=iframeElements[a_index-1] ; save to var
}
The reason to use a loop count instead of checking inside the array is because attempting to call an element of the array which does not exist will throw an error (could be caught with try).
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 245 guests