Quasar Jarosz Posted May 31, 2006 Share Posted May 31, 2006 This is my first time using IE.au3, so it's possible i'm missing something simple, but here is my issue: First, i'm using IE.au3 version T2.0-0. I'm also using the latest beta of AutoIt, version 3.1.1.125 I have a web page in which i want to click a link. _IELinkClickByText() seems like the perfect solution. Initially i was getting an error saying the link did not exist. After some research i found that my link is actually inside a frame, and that i might want to send the frame object into _IELinkClickByText() instead of the IE object. So i used _IEFrameGetObjByName() in an attempt to get the frame, but that fails with the following error: >Running:(3.1.1.125):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\IETests.au3" J:\autoit\lib\IE.au3 (884) : ==> The requested action with this object has failed.: If IsObj($o_object.document.parentwindow.frames ($s_Name, $i_index)) Then If ^ ERROR The exact code used was: $oFrame = _IEFrameGetObjByName ($oIE, "_svf0") _IELinkClickByText ($oFrame, "Administration - Product",1) I have no idea how to go about figuring out what is wrong here. I have also run into some other problems. I tried to use a piece of code from the IE.au3 help file to step over all frames in my document. The code was: $oFrames = _IEFrameGetCollection ($oIE) $iNumFrames = @extended For $i = 0 to ($iNumFrames - 1) $sFrameSrc = _IEFrameGetCollection ($oIE, $i).src MsgBox(0, "Frame Info", $sFrameSrc) Next However, this did not even pass the syntax checker: >Running AU3Check (1.54.1.1) params: from:C:\Program Files\AutoIt3\beta J:\autoit\src\IETests.au3(65,50) : ERROR: syntax error $sFrameSrc = _IEFrameGetCollection ($oIE, $i). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ So i modified it to work: $oFrames = _IEFrameGetCollection ($oIE) $iNumFrames = @extended For $i = 0 to ($iNumFrames - 1) $sFrameSrca = _IEFrameGetCollection ($oIE, $i) $sFrameSrc = $sFrameSrca.src MsgBox(0, "Frame Info", $sFrameSrc) Next But now i get this: >Running:(3.1.1.125):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\IETests.au3" J:\autoit\src\IETests.au3 (66) : ==> The requested action with this object has failed.: $sFrameSrc = $sFrameSrca.src $sFrameSrc = $sFrameSrca.src^ ERROR In fact, most of the time when i try to use a dot-anything (.<anything>, such as .src, .name, .value, etc) on an object variable, it fails. Usually with the same error as that above: "The requested action with this object has failed." Can someoen point me in the right direction? I have to imagine these are not normal problems - almost every function from IE.au3 i've tried has failed so far! Also, i'm running WinXP SP2 and IE 6.0.2900.2180.xpsp_sp2_gdr.050301-1519 (what a wonderful version number!) Thanks in advance! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted May 31, 2006 Share Posted May 31, 2006 So, my fault. It was a bonehead example. The syntax with .src was invalid, you were with to get an object variable first. The other issue is that the elements of the Frame collection turn out to be window objects instead of frames, so substituting .location.href for .src should work. With this information please do some more testing and then post about the troubles that remain. 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 1, 2006 Author Share Posted June 1, 2006 So, my fault. It was a bonehead example. The syntax with .src was invalid, you were with to get an object variable first. The other issue is that the elements of the Frame collection turn out to be window objects instead of frames, so substituting .location.href for .src should work. With this information please do some more testing and then post about the troubles that remain. Dale Modifying the example to step over the frames, using .location.href yielded: >Running:(3.1.1.125):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\IETests.au3" J:\autoit\src\IETests.au3 (66) : ==> The requested action with this object has failed.: $sFrameSrc = $sFrameSrca.location.href $sFrameSrc = $sFrameSrca.location.href^ ERROR Is there any way to trap these errors? or at least to get some more information about them? And - do you have any idea why I can't get _IEFrameGetObjByName() to work either? :-/ Just to make sure, i ran the same code on another machine - Windows 2000 Service Pack 4 (Build 5.00.2195.0004), running AutoIt version 3.1.1.123 and IE version 6.0.2800.1106CO. I get the exact same error as above, so my guess would be it's not something with any of my versions. Thanks for the quick response! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted June 1, 2006 Share Posted June 1, 2006 (edited) Modifying the example to step over the frames, using .location.href yielded: >Running:(3.1.1.125):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\IETests.au3" J:\autoit\src\IETests.au3 (66) : ==> The requested action with this object has failed.: $sFrameSrc = $sFrameSrca.location.href $sFrameSrc = $sFrameSrca.location.href^ ERROR Is there any way to trap these errors? or at least to get some more information about them? And - do you have any idea why I can't get _IEFrameGetObjByName() to work either? :-/ Just to make sure, i ran the same code on another machine - Windows 2000 Service Pack 4 (Build 5.00.2195.0004), running AutoIt version 3.1.1.123 and IE version 6.0.2800.1106CO. I get the exact same error as above, so my guess would be it's not something with any of my versions. Thanks for the quick response! QuasarYou can trap the errors simply by using _IEErrorHandlerRegister() You'll also get a diagnostic message to the SciTe console. Please post small reproducers of your problems? Use the _IE_Example() function if you can. For example, the following works for me... does it fail for you? #include <IE.au3> _IE_VersionInfo(); Show Version info to console $oIE = _IE_Example("frameset") $oFrame = _IEFrameGetObjByName($oIE, "Top") MsgBox(0, "FrameInfo", $oFrame.location.href) Exit Dale Edited June 1, 2006 by DaleHohm 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 1, 2006 Author Share Posted June 1, 2006 You can trap the errors simply by using _IEErrorHandlerRegister() You'll also get a diagnostic message to the SciTe console. Please post small reproducers of your problems? Use the _IE_Example() function if you can. For example, the following works for me... does it fail for you? #include <IE.au3> _IE_VersionInfo(); Show Version info to console $oIE = _IE_Example("frameset") $oFrame = _IEFrameGetObjByName($oIE, "Top") MsgBox(0, "FrameInfo", $oFrame.location.href) Exit Dale Alright, trying your example failed on the version of IE.au3 i had (2.0-0), so i upgraded to the latest (2.0-2), and it works. However.. this does not work on the new version, but does on the old: Func _IEFormElementGetObjByName_Test() _IE_VersionInfo(); $oIE = _IE_Example("form") $oForm = _IEFormGetObjByName($oIE, "ExampleForm") $oInput = _IEFormElementGetObjByName($oForm, "textExample") _IEFormElementSetValue($oInput, "test") EndFunc Which is one of the functions i need to use.. Here is the error: >Running:(3.1.1.123):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\tests.au3" --> IE.au3 Information from function _IE_VersionInfo, version T2.0-2 (Release date: 20060530) J:\autoit\lib\IE.au3 (1168) : ==> The requested action with this object has failed.: If IsObj($o_col) Then $i_length = $o_col.length If IsObj($o_col) Then $i_length = $o_col.length^ ERROR Also - This might be expected normal behavior, but if i try to get a frame which doesn't exist, i get: >Running:(3.1.1.123):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\tests.au3" --> IE.au3 Information from function _IE_VersionInfo, version T2.0-2 (Release date: 20060530) J:\autoit\lib\IE.au3 (729) : ==> The requested action with this object has failed.: $o_col = $o_object.document.parentwindow.frames ($s_Name) $o_col = $o_object.document.parentwindow.frames ($s_Name)^ ERROR When i call _IELinkClickByText(), do i need to send in the IE window, or the frame that contains the link? Thanks! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted June 1, 2006 Share Posted June 1, 2006 Alright, trying your example failed on the version of IE.au3 i had (2.0-0), so i upgraded to the latest (2.0-2), and it works. However.. this does not work on the new version, but does on the old: Func _IEFormElementGetObjByName_Test() _IE_VersionInfo(); $oIE = _IE_Example("form") $oForm = _IEFormGetObjByName($oIE, "ExampleForm") $oInput = _IEFormElementGetObjByName($oForm, "textExample") _IEFormElementSetValue($oInput, "test") EndFunc Which is one of the functions i need to use.. Here is the error: >Running:(3.1.1.123):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\tests.au3" --> IE.au3 Information from function _IE_VersionInfo, version T2.0-2 (Release date: 20060530) J:\autoit\lib\IE.au3 (1168) : ==> The requested action with this object has failed.: If IsObj($o_col) Then $i_length = $o_col.length If IsObj($o_col) Then $i_length = $o_col.length^ ERROR Also - This might be expected normal behavior, but if i try to get a frame which doesn't exist, i get: >Running:(3.1.1.123):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\tests.au3" --> IE.au3 Information from function _IE_VersionInfo, version T2.0-2 (Release date: 20060530) J:\autoit\lib\IE.au3 (729) : ==> The requested action with this object has failed.: $o_col = $o_object.document.parentwindow.frames ($s_Name) $o_col = $o_object.document.parentwindow.frames ($s_Name)^ ERROR When i call _IELinkClickByText(), do i need to send in the IE window, or the frame that contains the link? Thanks! QuasarOK, thanks. I now know how I broke the *GetObjByName functions in -2. I will have a new version posted shortly. 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 Link to comment Share on other sites More sharing options...
DaleHohm Posted June 1, 2006 Share Posted June 1, 2006 Please test with new version T2.0-3 and reporting any troubles. thanks, 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 2, 2006 Author Share Posted June 2, 2006 Please test with new version T2.0-3 and reporting any troubles. thanks, Dale Alright, it looks like everything is working properly now. The only one of my tests that fail is FrameSetTest_Error(), which is trying to do _IEFrameGetObjByName on a frame that i know does not exist. Seems like it should throw a NoMatch error instead of dying though I have a question though: I have a site with multiple levels of frames, and i want to drill down to a specific frame (in order to click a link in that frame). I can get the first frame, but all frames below that fail with this error: >Running:(3.1.1.123):C:\Program Files\AutoIt3\beta\autoit3.exe "J:\autoit\src\IETests.au3" J:\autoit\lib\IE.au3 (748) : ==> The requested action with this object has failed.: $o_col = $o_object.document.parentwindow.frames ($s_Name) $o_col = $o_object.document^ ERROR If i use _IEGetObjByName() instead of _IEFrameGetObjByName(), i don't get the script failure, however i just get NoMatch errors after the first frame. The code looks like this: $oFrame = _IEFrameGetObjByName ($oIE, "_sweclient") $oFrame1 = _IEFrameGetObjByName ($oFrame, "_swecontent") and... ;Attempt to get the object directly with IEGetObjByName $oFrame = _IEGetObjByName($oIE, "_sweclient") ;Attempt to get the next one $oFrame1 = _IEGetObjByName ($oFrame, "_swecontent") Is there some other object i need to get in the middle? the Frameset maybe? Thanks! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted June 2, 2006 Share Posted June 2, 2006 (edited) Thanks. After some testing it is clear that _IEFrameGetObjByName needs to work. For one thing, I have it set up to handle a situation where there are more than one frame of the same name... testing shows that the DOM access blows up if there are more than one frame or iframe of the same name, so it is unnecessary to allow for this and I'll simplify the routine accordingly. I'll also trap the error associated with referencing a non-existant name. Thanks for reporting this. Watch for it in the next release. Also note that you can avoid the aborting of your script by using _IEErrorHandlerRegister() This will instantiate a COM error handler to that COM errors do not abort your script, will display a console message when an error occurs and will return an @error status of $_IEStatus_ComError. Dale Update: I know I didn't answer your final questions yet -- I'll come back to it as I have not really digested the question yet. Edited June 2, 2006 by DaleHohm 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 2, 2006 Author Share Posted June 2, 2006 Thanks Dale. I'll wait for any input you can give on the proper way to go about finding my link. In the mean time, i'll continue testing as i get time and report back if i happen to get it to work, or if i break anything else. Thanks for your work! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted June 2, 2006 Share Posted June 2, 2006 I would expect this to wordk: $oFrame = _IEFrameGetObjByName ($oIE, "_sweclient") $oFrame1 = _IEFrameGetObjByName ($oFrame, "_swecontent") Try examining the HTML in the first frame to insure it includes the nested frame you are after: $oFrame = _IEFrameGetObjByName ($oIE, "_sweclient") ConsoleWrite(_IEBodyReadHTML($oFrame) & @CR) 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 2, 2006 Author Share Posted June 2, 2006 (edited) I would expect this to wordk: $oFrame = _IEFrameGetObjByName ($oIE, "_sweclient") $oFrame1 = _IEFrameGetObjByName ($oFrame, "_swecontent") Try examining the HTML in the first frame to insure it includes the nested frame you are after: $oFrame = _IEFrameGetObjByName ($oIE, "_sweclient") ConsoleWrite(_IEBodyReadHTML($oFrame) & @CR) Dale No, that fails too. _IEBodyReadHTML will not work on $oFrame In fact, "$oFrame.body" throws an "variable must be type Object" error. However, IsObj() is true on $oFrame, and ObjName() is "DispHTMLWindow2" Edited June 2, 2006 by Quasar Jarosz Link to comment Share on other sites More sharing options...
DaleHohm Posted June 2, 2006 Share Posted June 2, 2006 No, that fails too. _IEBodyReadHTML will not work on $oFrame In fact, "$oFrame.body" throws an "variable must be type Object" error. However, IsObj() is true on $oFrame, and ObjName() is "DispHTMLWindow2"_IEBodyReadHTML returns $o_object.document.body.innerHTML so if there is a document instantiated in that frame it should work. Try turning on the error handler to see if you might be gettin an Access is denied error: _IEErrorHandlerEnable() 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 Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted June 5, 2006 Author Share Posted June 5, 2006 _IEBodyReadHTML returns $o_object.document.body.innerHTML so if there is a document instantiated in that frame it should work. Try turning on the error handler to see if you might be gettin an Access is denied error: _IEErrorHandlerEnable() Dale There is no _IEErrorHandlerEnable() in the latest version. However, if i enable my own COM error handler (via _IEErrorHanderRegister()), the error description is: "Access is denied." This sounds a lot like $_IEStatus_AccessDenied to me, though it never actually throws that error. What does this mean? (sorry about being ignorent). I see your mention in the code about cross-site scripting security? What exactly is happening here? The frame points to different site than the parent frame? Thanks for your help! It's greatly appreciated! Quasar Link to comment Share on other sites More sharing options...
DaleHohm Posted June 5, 2006 Share Posted June 5, 2006 There is no _IEErrorHandlerEnable() in the latest version. However, if i enable my own COM error handler (via _IEErrorHanderRegister()), the error description is: "Access is denied." This sounds a lot like $_IEStatus_AccessDenied to me, though it never actually throws that error. What does this mean? (sorry about being ignorent). I see your mention in the code about cross-site scripting security? What exactly is happening here? The frame points to different site than the parent frame? Thanks for your help! It's greatly appreciated! QuasarSorry, sad when I can't remember my own code. It is of course_IEErrorHandlerRegister() Where I trap for the Access is Denied error I return the $_IEStatus_AccessDenied status. This is obviously a place I am not looking for that. My goal has been to trap the most common occurances of COM errors and try to give more guidance... this may be another place I can do that... I'll look into it. Yes, the Access Is Denied error is triggered when the parent and child are from different sites. It is imposed by the DOM to prevent impersonation. Although it would be fine to allow this access in a desktop application like this, on the Internet it is a dangerous thing and we therefore have to live with the restriction as well. The only suggestion that I have for you would be to display the frame contents in a new window instead of trying to manipulate it in the frame. So long as what is in the frame does not rely on communications with other frames (which presumably it could not due to the same restrictions) then it should work fine. 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 Link to comment Share on other sites More sharing options...
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