Jump to content

The requested action with this object has failed


 Share

Recommended Posts

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

Link to comment
Share on other sites

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

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 by Nine
Link to comment
Share on other sites

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

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

@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 by Danp2
Link to comment
Share on other sites

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 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

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

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

  • 1 month later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...