OneGoat Posted July 31, 2008 Posted July 31, 2008 (edited) After a few days of testing and searching and retrying everything I could think of I've decided to finally ask a question. I have found an iFrame that is being used as a form element. I'm trying to gain control of it and read its html (write to console). The html source looks like this: (iframe and form highlighted in red) CODE <form name="aspnetForm" method="post" action="/Modules/Applications/Pages/Canvas.aspx?appId=104283" id="aspnetForm"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEyNDc3NTQwNjhkZA==" /> </div> <script type="text/javascript"> <!--var FIM_advAppId = 104283;var FIM_baseAdvId = null;// --> </script> <div id="topLinks" class="clearfix" <div id="canvasPageTitle"> <img alt="Application Icon" style="vertical-align: bottom;" src="http://a52.ac-images.myspacecdn.com/images01/44/l_b880ac2810ea661ae851b4157f43ede3.png" /><span id="applicationTitle">Mobsters</span> </div> <div id="pageLinks" class="right"> <a href='http://apps.myspace.com/Modules/AppGallery/Pages/featuredappgallery.aspx?fuseaction=apps'>MySpace Apps</a> | <a href='http://profileedit.myspace.com/index.cfm?fuseaction=accountSettings.applicationSettings'>View My Apps</a> </div> </div> <script type="text/javascript"> if(top != self) top.location = location; </script> <iframe id="apppanel_104283_canvas" name="apppanel_104283_canvas" src="http://api.msappspace.com/apprendering/104283/canvas/render.app#qfvA5CsqQAC7H4t26tAvmDftkJdOsgvHzjnMBdKBMLSugbH8oLf91HRanuH%2bns7Gpv1MTwDoByoVvh0CbQDE3g%2frLHPPgcBpK0UuoTPB60U%3d&opensocial_surface=canvas&ownerId=30018896&installState=1&country=US&lang=en" width="100%" height="2850" scrolling="no" frameborder="0" allowtransparency="true" style="border: none; background:transparent;"></iframe><br /> </form> I have tried gaining control and read the html of this using the following code: $oForm = _IEFormGetObjByName($oDiv, "aspnetForm") ConsoleWrite( "--!-!-------------" & @CRLF) ConsoleWrite( "FORM Unique ID:" & _IEPropertyGet($oForm, "uniqueid") & @CRLF) ConsoleWrite( "FORM Location URL:" & _IEPropertyGet($oForm, "locationurl") & @CRLF) ConsoleWrite( "FORM Id:" & $oForm.id & @CRLF) $oFrame = _IEFrameGetObjByName($oForm, "apppanel_104283_canvas") ConsoleWrite(_IEBodyReadHTML($oFrame) & @CR) I have also looped through all frames on the page using the $oFrame = _IEFrameGetCollection($oIE, X);<---- with X being 1 2 or 3 (3 frames on page) Both of these give me the same error C:\Program Files\AutoIt3\Include\IE.au3 (2210) : ==> The requested action with this object has failed.: Return $o_object.document.body.innerHTML Return $o_object.document^ ERROR ->10:19:07 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 12.211 I read a bunch of topics on this message board and tried a lot of approaches, for instance I downloaded Debugbar for IE. I found the path to the link that I'm ultimately trying to click is inside this particular iFrame, and the path looks like this (pseudo) <div id="wrap"> <form name="aspnetform"> <IFRAME id=apppanel_104283> <DIV name="mainframe"> <DIV> (no name) <TABLE> <TD> <TR> <SPAN> MY LINK </SPAN> </TR> </TD> </TABLE> </DIV> </DIV> </IFRAME> </FORM> </div> I am hoping for some enlightenment. I really hope I provided enough information too. Cheers, Goat. - Instant Edit - I also used this example script: CODE #include <IE.au3> _IEErrorHandlerRegister() $oIE = _IEAttach("MySpace - Windows Internet Explorer", "WindowTitle", 1) Sleep(3000) WinActivate("MySpace - Windows Internet Explorer") ;_IELinkClickByText ($oIE, "My Mob") Sleep(2000) $colFrames = _IEFrameGetCollection($oIE) $iFrameCnt = @extended ConsoleWrite("There are " & $iFrameCnt & " frames." & @LF) For $i = 0 To $iFrameCnt - 1 $oFrame = _IEFrameGetCollection($oIE, $i) MsgBox(0, 0, "Frame " & $i & ":" & _IEBodyReadHTML($oFrame) & @LF) Next MsgBox(0, 0, $i) It produced the same error. Edited July 31, 2008 by OneGoat
OneGoat Posted July 31, 2008 Author Posted July 31, 2008 The Edit button seems to have disappeared from my first post :<AutoIt v3.2.12.1IE.au3 Newest Version
DaleHohm Posted July 31, 2008 Posted July 31, 2008 Please add this to yout code to get a more complete COM error: _IEErrorHandlerRegister() I will guess you will see an "access is denied" error. This is because the source of the frame is in a different domain than the container page. This triggers a cross-site frame security restriction in the DOM. Assuming htis is the case, your recourse is to open the frame source (src=) in a new window. This may or may not work subject to additional server-side processing that is done. 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
OneGoat Posted July 31, 2008 Author Posted July 31, 2008 I will guess you will see an "access is denied" error. This is because the source of the frame is in a different domain than the container page. This triggers a cross-site frame security restriction in the DOM. Assuming htis is the case, your recourse is to open the frame source (src=) in a new window. This may or may not work subject to additional server-side processing that is done.Dale, You're right about the Access is Denied error. I manually opened the iFrame's src in a new window and got a Script error "Access is Denied" popup window from DebugBar inside IE7. Line: 262Character: 14Code: 0Error Message: Permission deniedURL: http://profile.myspace.com/Modules/Common/...c_relay002.htmlHOWEVER, I am now able to manipulate the frame elements which I could not before. Is there a way to automate this process of opening the form into a new window? If I could figure out how to retrieve the SRC property then I could _IENavigate() I suppose. I just need a way to grab the SRC of the iFrame.
DaleHohm Posted July 31, 2008 Posted July 31, 2008 $oFrame = _IEGetObjById($oIE, "apppanel_104283_canvas") $sSrc = $oFrame.src $oIE2 = _IECreate($sSrc) 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
OneGoat Posted July 31, 2008 Author Posted July 31, 2008 $oFrame = _IEGetObjById($oIE, "apppanel_104283_canvas") $sSrc = $oFrame.src $oIE2 = _IECreate($sSrc) Dale This worked. It opens in a new window and THEN I can get to the frame's source (and thus its objects). Thank you so much for the help. Goat.
misjdd Posted October 15, 2008 Posted October 15, 2008 (edited) I cannot seem to be able to grab the source of the iFrame you are referring to. Have you had any luck? I would like to create a script that auto heals my Mobster and this seems like the most reliable way to do it. Can anyone help? To clarify, I need to understand the logic of the script. You grab the form element by ID and get the Iframe.src. Then IENavigate to the source of the I frame and from there I should be able to manipulate a click onto the Hospital button? Thanks! Edited October 15, 2008 by misjdd
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now