Marga Posted April 17, 2019 Share Posted April 17, 2019 This is my first question and I do not know much English, so the first thing is to apologize. I execute this code in a loop and it usually works, but there are times when I get an error, I think it's because it takes the window to refresh but I can not solve it. Any ideas? Thank you. $oFrameNavegacion = _IEFrameGetObjByName($oIE, "navegacion") if @error Then FileWrite($hFileOpen, "$oFrameNavegacion error: " & @error & @CRLF) Else $oForm1 = _IEFormGetObjByName ($oFrameNavegacion, "form1") if @error Then FileWrite($hFileOpen, "$oFormListados error: " & @error & @CRLF) Else $oTable = _IETableGetCollection($oForm1,3) The ERROR is: Line 1509 (IE.au3) Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length Case $iIndex > -1 And $iIndex < $oObject^ERROR Error: The requested action with this object has failed. Link to comment Share on other sites More sharing options...
Nine Posted April 17, 2019 Share Posted April 17, 2019 (edited) Show more of your code, we don't even see $oObject. Make it short and runable. ps. when you post code, please use <> just before emoticon. Edited April 17, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted April 17, 2019 Share Posted April 17, 2019 @Nine The error is occurring inside the function _IETableGetCollection. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Marga Posted April 17, 2019 Author Share Posted April 17, 2019 Just now, Danp2 said: @Nine The error is occurring inside the function _IETableGetCollection. Yes, but I call IETableGetCollection many times and it onlu ever fails Thanks Link to comment Share on other sites More sharing options...
Marga Posted April 17, 2019 Author Share Posted April 17, 2019 Func _IETableGetCollection(ByRef $oObject, $iIndex = -1) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf ; $iIndex = Number($iIndex) Select Case $iIndex = -1 Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _ $oObject.document.GetElementsByTagName("table")) Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _ $oObject.document.GetElementsByTagName("table").item($iIndex)) Case $iIndex < -1 __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1") Return SetError($_IESTATUS_InvalidValue, 2, 0) Case Else __IEConsoleWriteError("Warning", "_IETableGetCollection", "$_IESTATUS_NoMatch") Return SetError($_IESTATUS_NoMatch, 1, 0) EndSelect EndFunc ;==>_IETableGetCollection This is the _IETableGetCollection method Link to comment Share on other sites More sharing options...
Danp2 Posted April 17, 2019 Share Posted April 17, 2019 This has come up before. Here's another example -- Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 17, 2019 Share Posted April 17, 2019 (edited) 1 hour ago, Danp2 said: The error is occurring inside the function _IETableGetCollection. I see... 58 minutes ago, Marga said: Yes, but I call IETableGetCollection many times and it onlu ever fails Is this site publicly accessible ? When it is happening, have you look at the DOM ? Have you been able to reproduce the error when it is happening with a shorter script that only try to get the same collection ? ps. when you post code, please use <> just before emoticon. Edited April 17, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Marga Posted April 17, 2019 Author Share Posted April 17, 2019 4 hours ago, Danp2 said: Esto ha llegado antes. Aquí hay otro ejemplo: Thanks, I have reviewed and its solution was that I copy the code and the function. It happens to me in several programs that I've done with IE Link to comment Share on other sites More sharing options...
Marga Posted April 17, 2019 Author Share Posted April 17, 2019 4 hours ago, Nine said: I see... Is this site publicly accessible ? When it is happening, have you look at the DOM ? Have you been able to reproduce the error when it is happening with a shorter script that only try to get the same collection ? ps. when you post code, please use <> just before emoticon. Yes, it is public access. I will try to make a shorter code and upload it. Thank you Link to comment Share on other sites More sharing options...
Danp2 Posted April 17, 2019 Share Posted April 17, 2019 (edited) @Marga FYI, I don't believe just copying / pasting the code will solve the issue. I believe this is a timing issue, where perhaps the website is refreshed in the background and the IE object get invalidated. If we can replicate the issue on demand, then it should be possible to update the UDF to fix the problem. Edit: I also found the following information -- https://www.autoitscript.com/forum/topic/174191-ieau3-_ietablegetcollection-repeated-execution-issue/?_fromLogin=1 https://www.autoitscript.com/trac/autoit/ticket/3097 Edited April 17, 2019 by Danp2 Marga 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jdelaney Posted April 17, 2019 Share Posted April 17, 2019 (edited) Throw in a com error handler. When the IE browser in not in a ready state, you cannot access the DOM, so then when you attempt to access child objects, and their properties, things blow up. It's a limitation of some of the _IE functions which always assume the browser is in a ready state. For example, when the browser window is hung: _WinAPI_IsHungAppWindow http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(IsHungAppWindow);k(DevLang-C);k(TargetOS-WINDOWS)&rd=true My workaround was to create wrapping functions around the IE ones which would re-try a few times (variably set), and check window states on failures/wait (and DOM states). Edited April 17, 2019 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Marga Posted April 25, 2019 Author Share Posted April 25, 2019 On 4/17/2019 at 8:20 PM, Danp2 said: @Marga FYI, I don't believe just copying / pasting the code will solve the issue. I believe this is a timing issue, where perhaps the website is refreshed in the background and the IE object get invalidated. If we can replicate the issue on demand, then it should be possible to update the UDF to fix the problem. Edit: I also found the following information -- https://www.autoitscript.com/forum/topic/174191-ieau3-_ietablegetcollection-repeated-execution-issue/?_fromLogin=1 https://www.autoitscript.com/trac/autoit/ticket/3097 Exactly this is my problem. I have read the links, and I have tried to compile with x86 and to put sleep but it still does not work. My impression is that the object is lost because the page is refreshed just after obtaining the Form and before objener the Tag. Many thanks. Keep investigating. Link to comment Share on other sites More sharing options...
Marga Posted April 25, 2019 Author Share Posted April 25, 2019 On 4/18/2019 at 1:13 AM, jdelaney said: Throw in a com error handler. When the IE browser in not in a ready state, you cannot access the DOM, so then when you attempt to access child objects, and their properties, things blow up. It's a limitation of some of the _IE functions which always assume the browser is in a ready state. For example, when the browser window is hung: _WinAPI_IsHungAppWindow http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(IsHungAppWindow);k(DevLang-C);k(TargetOS-WINDOWS)&rd=true My workaround was to create wrapping functions around the IE ones which would re-try a few times (variably set), and check window states on failures/wait (and DOM states). This is what I've been trying to do for some time, but I can not capture the error. I will try to use other functions of _IE instead of those that are failing me. Thank you. Link to comment Share on other sites More sharing options...
jdelaney Posted April 25, 2019 Share Posted April 25, 2019 It's something like _ieerrorhandlerregister. our you can add in your own COM error handler. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Marga Posted May 30, 2019 Author Share Posted May 30, 2019 On 4/25/2019 at 2:28 PM, jdelaney said: It's something like _ieerrorhandlerregister. our you can add in your own COM error handler. Thanks, I add my COM error handler. 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