Sign in to follow this  
Followers 0
misjdd

Gaining Access to controls in an IFrame via *_IE functions

8 posts in this topic

OK. I have read several forums and posts and I am still a little short on knowledge for how to do this. I want to do an _IELinkClickByText on a link inside of an Iframe whose source is on a different domain. From what I understand, I can open the source of the Iframe in a new window (this works OK) to avoid the DOM security issue of cross domain scripting. However, when the source is opened, I still get access denied errors.

I am not going to bother posting my code because it is certainly not even close to correct, but can someone give me an example of code for the following scenario?

The main page has 3 frames... FRAME2 is the one with the content i want to access

FRAME2 has a form on it... lets call it FORM1

Inside that form is an iframe whose source is on a different domain ... lets call the iframe IFRAME1

The links that I want to access are inside of the Iframe ... LINK1 LINK2 LINK3

So basically I am asking for code or pseudo code to access those links, assuming that there is not some inherited security issue.

Thanks in advance. I am VERY new to the IE.au3 code so it is still foggy in my head. Everyone hates newbs, I know :P

Share this post


Link to post
Share on other sites



OK. I have read several forums and posts and I am still a little short on knowledge for how to do this. I want to do an _IELinkClickByText on a link inside of an Iframe whose source is on a different domain. From what I understand, I can open the source of the Iframe in a new window (this works OK) to avoid the DOM security issue of cross domain scripting. However, when the source is opened, I still get access denied errors.

I am not going to bother posting my code because it is certainly not even close to correct, but can someone give me an example of code for the following scenario?

The main page has 3 frames... FRAME2 is the one with the content i want to access

FRAME2 has a form on it... lets call it FORM1

Inside that form is an iframe whose source is on a different domain ... lets call the iframe IFRAME1

The links that I want to access are inside of the Iframe ... LINK1 LINK2 LINK3

So basically I am asking for code or pseudo code to access those links, assuming that there is not some inherited security issue.

Thanks in advance. I am VERY new to the IE.au3 code so it is still foggy in my head. Everyone hates newbs, I know :(

Cross-domain scripting limitations are built in to IE. You can get the source URL of the iFrame, and then try to open that in its own instance of IE or a tab (if IE7). Some sites don't allow that page to be loaded directly, in which case you're out of luck.

You won't know until you try.

:P


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

Cross-domain scripting limitations are built in to IE. You can get the source URL of the iFrame, and then try to open that in its own instance of IE or a tab (if IE7). Some sites don't allow that page to be loaded directly, in which case you're out of luck.

You won't know until you try.

:P

OK... I did that and it works! But I still don't see how to "click" the control I am trying to drill to... here is the structure according to DebugBar:

<document>

<html>

<body>

<DIV class=mainFrame id=mainFrame>

<DIV class=tabContainer>

<DIV id=tabsDiv>

<table>

<tbody>

<tr>

<td>

<SPAN class=selectedTab style="CURSOR: pointer" jQuery1224424411281="14">Main</SPAN>

Now... here is a snippet of my code:

$mainFrame = _IEGetObjById($oFrame,"mainFrame")

$Tabs = _IEGetObjById($mainFrame,"tabsDiv")

When I do the _IETableGetCollection on the $Tabs ... It sees the table... but how can I simulate a click onto the Span item?

Thanks in advance!

Share this post


Link to post
Share on other sites

Hint: _IETagnameGetCollection( , "span", index) and _IEAction( , "click")


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

Hint: _IETagnameGetCollection( , "span", index) and _IEAction( , "click")

OK that worked! I found that I do not need to drill down into the mainframe DIV or the tabsDiv DIV items either... I do have another challenge and that is that the other location I need to click is inside of the following structure:

<DIV>

<DIV>

<DIV>

<TABLE>

<TBODY>

<TR>

<TD>

<DIV class=buttonDiv>

<A class="button button_blue" href="#">

<SPAN>Attack

This page has hundreds of DIVs and SPANs so I am wondering if I can get the tag by class somehow?

Hopefully other people who read this can get a better feel for how to use the AWESOME IE.au3 features too!

THanks again!

Share this post


Link to post
Share on other sites

Hint: _IETagnameGetCollection( , "span", index) and _IEAction( , "click")

Actually I got it now:

$oInputs = _IETagnameGetCollection( $oie , "span")

For $oInput In $oInputs

$test = _iepropertyget($oInput, "innerhtml")

if $test = "Hit List" then $hit = $oInput

if $test = "Main" then $main = $oInput

if $test = "Hospital" then $hospital = $oInput

if $test = "Attack" then $attack = $oInput

if $test = "Fight" then $fight = $oInput

if StringInStr($test, "Heal yourself") then $healyourself = $oInput

if $test = "Bank" then $bank = $oInput

if $test = "Deposit" then $deposit = $oInput

Next

I am having trouble grabbing a DIV item, but I think I get the concept enough to figure it out on my own. Thanks Dale for your help!

Share this post


Link to post
Share on other sites

Cross-domain scripting limitations are built in to IE. You can get the source URL of the iFrame, and then try to open that in its own instance of IE or a tab (if IE7). Some sites don't allow that page to be loaded directly, in which case you're out of luck.

You won't know until you try.

If you cannot access the iFrame in it's own window, am I S.O.L. if scripting with AutoIt?

Share this post


Link to post
Share on other sites

Probably, but the limitation is not AutoIt's. It's an intended behavior of the IE DOM.

:)


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

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