Jump to content

IE.au3 - The requested action with this object has failed.


Recommended Posts

Hey fellas,

I'm using IE.au3 and _IETableGetCollection and recently found out that when I use it more than three times I get this error:

"C:\Program Files (x86)\AutoIt3\Include\IE.au3" (1508) : ==> The requested action with this object has failed.:
Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length
Case $iIndex > -1 And $iIndex < $oObject.document^ ERROR

The script is set on a while loop with a hotkey to a function. The thing is I'm not reloading the page, the page stays as it is. Three times it works but the fourth time I get above error. When I restart the script I am again able to do it three times.

Is there a way to troubleshoot this?

Thanks

Link to comment
Share on other sites

3 minutes ago, Danp2 said:

Why? Please explain.

You may want to review this thread.

Not sure if I'll be able to reproduce it on a different website since my code is several thousand lines.

I'll try to go back a version or two of my script to see when the issue originated to narrow it down.

I'm going to check the thread as well. Thanks for the tip

Link to comment
Share on other sites

So tried using one of my earlier versions and it worked great. So this morning I set out to figure out what I've changed in the newer versions which made it give out that error.

To my surprise the old version which worked perfectly yesterday started giving me errors today.

I don't understand :-/

Link to comment
Share on other sites

1 hour ago, Seminko said:

So tried using one of my earlier versions and it worked great. So this morning I set out to figure out what I've changed in the newer versions which made it give out that error.

To my surprise the old version which worked perfectly yesterday started giving me errors today.

I don't understand :-/

Did it fail after multiple loops or on the initial attempt?

18 minutes ago, Seminko said:

So I made a custom script where I put all the _IETableGetCollection functions I use in my original script. It works... Dang it...

You are headed down the correct path to isolate the issue. Just keep at it...

Link to comment
Share on other sites

Ok, so I used _ArrayDisplay after each _IETableGetCollection call to try to isolate where the script bugs out. Tried 10 times, everytime it bugs out at the third call. Not true, tried some more times and it varies :-/

Here an exerpt from my script:

Func CalculateOvertime()
    If ProcessExists("IEXPLORE.exe") Then
        Local $oTable2 = _IETableGetCollection($oIE, 26) ; Gets the table with working hours
        If @error Then
            MsgBox(16, "Whoopsie!", "Even though you're awesome," & @CRLF & @CRLF & "you probably don't have WebTarget open.")
        Else
            $aTableData = _IETableWriteToArray ($oTable2) ; Transforms the table into an array
            If $aTableData[0][0] = "" Then
                _ArrayDelete($aTableData, 0)
                $TableForOvertimesID = 70
                $TableForNahradniVolnoID = 59
                $TableForDruhaStrankaSaldaID = 79
                _ArrayDisplay($aTableData)
            EndIf
            _ArrayDisplay($aTableData)
            $iCols = Ubound($aTableData, 2) ; Gets the number of columns / days
            If $iCols < 28 Then
                MsgBox(48, "Whoopsie!", "Even though you're awesome," & @CRLF & @CRLF & "you probably don't have your attendace sheet open.")
            Else
                ;MsgBox(1, "", $iCols)
                Local $aSmallArray[$iCols][$iCols] ; Makes the array more compact so it shows only "Rozdil fondu" and "Plan do"
                For $i = 1 To $iCols-1
                    $aSmallArray[$i][0] = $aTableData[8][$i] ; Rozdil fondu
                    $aSmallArray[$i][1] = $aTableData[10][$i] ; Plan do
                Next
                ;_ArrayDisplay($aSmallArray)
                Local $aSmallArrayComma[$iCols][$iCols] ; Replaces all czech commas for us decimal points
                For $i = 1 To $iCols-1
                    $aSmallArrayComma[$i][0] = StringReplace($aSmallArray[$i][0],",",".")
                    $aSmallArrayComma[$i][1] = $aSmallArray[$i][1]
                Next
                ;_ArrayDisplay($aSmallArrayComma)
                
                ;*** THIS IS WHERE IT BUGS OUT *************************
                Local $oTableNahradniVolno = _IETableGetCollection ($oIE, $TableForNahradniVolnoID) ; This will check for 'Nahradni volno' value
                $aTableDataNahradniVolno = _IETableWriteToArray ($oTableNahradniVolno)
                _ArrayDisplay($aTableDataNahradniVolno)
                ;*** THIS IS WHERE IT BUGS OUT *************************

As stated above the issue is with this:

Local $oTableNahradniVolno = _IETableGetCollection ($oIE, $TableForNahradniVolnoID)

I tried replacing the variable with a fixed value but it bugged out again.

What I don't get is that even though I don't reload the page it can bug out. First couple of goes it grabs the table no problem. But the third / fourth time it bugs.

 

EDIT: I've even tried below to try to check whether _IETableGetColletction would give an @error, but it doesn't... I'm gonna go insanse...

Local $oTableNahradniVolno = _IETableGetCollection($oIE, 59) ; This will check for 'Nahradni volno' value
If @error Then
    MsgBox(1, "", "error")
EndIf

 

Edited by Seminko
Link to comment
Share on other sites

Did this little thing which works perfectly. So let me recap:

  • in script below _IETableGetCollection works perfectly
  • in script above it bugs out
  • it doesn't respond to If @error then
  • But it gives this error (console) which points to IE.au3 to the _IETableGetCollection function
    • "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (1508) : ==> The requested action with this object has failed.
    • Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length
    • Case $iIndex > -1 And $iIndex < $oObject.document^ ERROR
  • it seems like something else in my original script above is influencing what is going on with _IETableGetCollection but how could it?
#include <IE.au3>
#include <Array.au3>

HotKeySet("^l", "LaunchWebTarget")
;HotKeySet("^!l", "LaunchWebTargetLeader")
HotKeySet("{F8}", "Terminate")

While 1
    Sleep(100)
WEnd

Func LaunchWebTarget()
    $TableForOvertimesID = 69
    $TableForNahradniVolnoID = 58
    $TableForDruhaStrankaSaldaID = 78

    Global $oIE = _IEAttach("https://sitedot.com", "url")

    Local $oTable2 = _IETableGetCollection($oIE, 26) ; Gets the table with working hours
    If @error Then
        MsgBox(16, "Whoopsie!", "Even though you're awesome," & @CRLF & @CRLF & "you probably don't have WebTarget open.")
    EndIf
    $aTableData = _IETableWriteToArray ($oTable2) ; Transforms the table into an array
    _ArrayDisplay($aTableData)

    Local $oTableNahradniVolno = _IETableGetCollection($oIE, $TableForNahradniVolnoID) ; This will check for 'Nahradni volno' value
    If @error Then
        MsgBox(1, "", "error")
    EndIf
    $aTableDataNahradniVolno = _IETableWriteToArray ($oTableNahradniVolno)
    _ArrayDisplay($aTableDataNahradniVolno)

    Local $CurrentMonthColleciton = _IETableGetCollection($oIE, 13) ; This will check for 'Nahradni volno' value
    $CurrentMonthArray = _IETableWriteToArray($CurrentMonthColleciton)
    _ArrayDisplay($CurrentMonthArray)

    Local $oTablePagesSaldo = _IETableGetCollection ($oIE, $TableForDruhaStrankaSaldaID)
    $oTableDataPagesSaldo = _IETableWriteToArray ($oTablePagesSaldo)
    _ArrayDisplay($oTableDataPagesSaldo)

    Local $oTableOvertime = _IETableGetCollection ($oIE, $TableForOvertimesID)
    $aTableDataOvertime = _IETableWriteToArray ($oTableOvertime)
    _ArrayDisplay($aTableDataOvertime)
EndFunc


Func Terminate()
   Exit
EndFunc

 

Edited by Seminko
Link to comment
Share on other sites

If $aTableData[0][0] = "" Then
                _ArrayDelete($aTableData, 0)
                $TableForOvertimesID = 70
                $TableForNahradniVolnoID = 59
                $TableForDruhaStrankaSaldaID = 79
                _ArrayDisplay($aTableData)
            EndIf

Only thing jumping out at me is that you only set the value of these variables when $aTableData[0][0] = "". Yet you use the variable here even though it may not have been initialized --

                ;*** THIS IS WHERE IT BUGS OUT *************************
                Local $oTableNahradniVolno = _IETableGetCollection ($oIE, $TableForNahradniVolnoID) ; This will check for 'Nahradni volno' value
Link to comment
Share on other sites

1 minute ago, Danp2 said:
If $aTableData[0][0] = "" Then
                _ArrayDelete($aTableData, 0)
                $TableForOvertimesID = 70
                $TableForNahradniVolnoID = 59
                $TableForDruhaStrankaSaldaID = 79
                _ArrayDisplay($aTableData)
            EndIf

Only thing jumping out at me is that you only set the value of these variables when $aTableData[0][0] = "". Yet you use the variable here even though it may not have been initialized --

                ;*** THIS IS WHERE IT BUGS OUT *************************
                Local $oTableNahradniVolno = _IETableGetCollection ($oIE, $TableForNahradniVolnoID) ; This will check for 'Nahradni volno' value

They are set way above that excerpt. Those are numbers of the tables that need to be checked. They vary between scenarios when an employee is checking the attendance and when a member of management is checking it.

 

This is what I'm doing now, I'm copying the script from one file to another, part by part and checking whether it works or not.

Now get this. In my original au3 file I have commented out every other function but the core one which actually calculates the attendance. In the new au3 file I have the EXACT SAME THING as in the original except for the commented parts. HOWEVER, the original files bugs out, and the new one does not...

I feel like crazy o.O

Link to comment
Share on other sites

  • 4 years later...

Thanks to @jpm it is fixed in recent beta. Take a look here for AutoIt v3.3.15.4 Beta:

This version fixes:

Quote

- Fixed #3167: Com error handler not called.

https://www.autoitscript.com/trac/autoit/ticket/3167

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
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
 Share

  • Recently Browsing   0 members

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