Seminko

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

13 posts in this topic

#1 ·  Posted

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

Share this post


Link to post
Share on other sites



#2 ·  Posted

Post a script using a publicly available website that demonstrates the issue.

Share this post


Link to post
Share on other sites

#3 ·  Posted

3 minutes ago, Danp2 said:

Post a script using a publicly available website that demonstrates the issue.

Well that's gonna be a problem...

Share this post


Link to post
Share on other sites

#4 ·  Posted

46 minutes ago, Seminko said:

Well that's gonna be a problem...

Why? Please explain.

You may want to review this thread.

Share this post


Link to post
Share on other sites

#5 ·  Posted

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

Share this post


Link to post
Share on other sites

#7 ·  Posted

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

Share this post


Link to post
Share on other sites

#8 ·  Posted

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted

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

Share this post


Link to post
Share on other sites

#12 ·  Posted

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

Share this post


Link to post
Share on other sites

#13 ·  Posted

Ok, I copied it piece by piece to a new file and the error is gone.

I'm glad but on the other hand I'm pissed I don't know what caused the error. Now I can only hope it will not return.

If it does, I'll report back.

Share this post


Link to post
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