Sign in to follow this  
Followers 0
vcrocca

The Requested action with this object has failed

11 posts in this topic

Wrote a script that opens a web page and downloads the body content and then converts it to a text file. The text file is then parsed by an external system looking for specific content. If the content is missing an alert is generated.

Problem occurs when the web site the script is accessing is non responsive. I receive the following error:

Line -1:

Error: The requested action with this object has failed

The script keeps functioning until the iExplore process consumes all available memory on the system and then the script crashes. IE7 with all the latest updates is being used.

The code is below:

[/code]
; ************************************************************************
; Script will connect to a web site specified in the command line
; Download the html output to a variable and then convert the information
;between the Body Tags to text
; *************************************************************************
#include <IE.au3>; Internet explorer include
#include <file.au3>; File and Directory Operations include
#NoTrayIcon; Hide tray icon

_IELoadWaitTimeout (20000); Set IE Timeout to load web page within 20 seconds
$oIE = _IECreate($cmdline[1], 0, 0, 1); Silently open web page that was provided as command line switch 
$sText = _IEBodyReadText($oIE); convert web site from HTML to Text
_IEQuit($oIE); close IE window
$file = FileOpen($cmdline[2], 2); Open file to write text to 

If $file = -1 Then; verify that file opens correctly
    Exit; exit script if it does not 
EndIf
_FileWriteLog($cmdline[2], $sText); write text to file specified in command line switch number two
FileClose($file); close text file
Exit; exit script[code]

Any help woould be appreciated.

Share this post


Link to post
Share on other sites



For a start, you could simply check if the site is available before taking actions with it. Also, try to run it without compiling it, so you know exactly where it's crashing.

You could also check the value of @error after IECreate. If its value is 6, then you'll know that the page didn't respond and you'll make it try again.

Share this post


Link to post
Share on other sites

For a start, you could simply check if the site is available before taking actions with it. Also, try to run it without compiling it, so you know exactly where it's crashing.

You could also check the value of @error after IECreate. If its value is 6, then you'll know that the page didn't respond and you'll make it try again.

Thanks but the reason for the script is to determine when a web site does not respond or when its missing content. If the web page does not respond or does not provide the correct content then we will raise an alert.

When the script crashes because the web site is not responsive nothing get returned so it alarms. The problem is the script crashes and continues to generate alerts even if the web site come right back online.

I hope this clarifies it a bit.

Share this post


Link to post
Share on other sites

If this is reproducible, please execute from SciTe, turn on SciTe debug mode (see my sig), add _IEErrorHandlerRegister() to your script and post the full output sent to the SciTe console. Also see if you can describe more about the site you are testing.

There may be better ways to do this (like InetGet or XMLHTTPRequest).

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If this is reproducible, please execute from SciTe, turn on SciTe debug mode (see my sig), add _IEErrorHandlerRegister() to your script and post the full output sent to the SciTe console. Also see if you can describe more about the site you are testing.

There may be better ways to do this (like InetGet or XMLHTTPRequest).

Dale

Thanks Dale

I did as you instructed and was able to reproduce the error. Below is the debug log.

!> Starting in DebugMode..

Line: @error-@extended: Line syntax

0006: 0-0: $var1 = 0

0008: 0-0: #AutoIt3Wrapper_run_debug_mode=Y

0010: 0-0: #include <IE.au3> ; Internet explrer include

0011: 0-0: #include <file.au3> ; File and Directory Operations include

0012: 0-0: #NoTrayIcon ; Hide tray icon

0013: 0-0: While $var1 = 0

0014: 0-0: _IELoadWaitTimeout(20000); Set IE Timeout to load web page within 20 seconds

0015: 0-0: $oIE = _IECreate("www.removed.com", 0, 1, 0) ; Silently open web page that was provided as command line switch

0016: 0-0: $sText = _IEBodyReadText($oIE) ; convert web site from HTML to Text

C:\Program Files\AutoIt3\Include\IE.au3 (2143) : ==> The requested action with this object has failed.:

Return $o_object.document.body.innerText

Return $o_object.document^ ERROR

->13:17:31 AutoIT3.exe ended.rc:1

+>13:17:32 AutoIt3Wrapper Finished

>Exit code: 1 Time: 1.680

I modified the script a bit to take the cmdline items out. The code used is here

[/code]

; ************************************************************************
; Script will connect to a web site specified in the command line
; Download the html output to a variable and then convert the information
;between the Body Tags to text
; *************************************************************************
$var1 = 0

    #AutoIt3Wrapper_run_debug_mode=Y

    #include <IE.au3>; Internet explrer include
    #include <file.au3>; File and Directory Operations include
    #NoTrayIcon; Hide tray icon
While $var1 = 0
    _IELoadWaitTimeout(20000); Set IE Timeout to load web page within 20 seconds
    $oIE = _IECreate("www.removed.com", 0, 1, 0); Silently open web page that was provided as command line switch
    $sText = _IEBodyReadText($oIE); convert web site from HTML to Text
    _IEQuit($oIE); close IE window
    $file = FileOpen("c:\temp\ib.txt", 2); Open file to write text to

    If $file = -1 Then; verify that file opens correctly
        Exit; exit script if it does not
    EndIf

    _FileWriteLog($file, $sText); write text to file specified in command line switch number two
    FileClose($file); close text file
    Sleep(120000)
    WEnd
[code]

I decided against using the INETGET function because I did not see where I could set a timeout value if the web page did not respond.

Thanks again.

Edited by vcrocca

Share this post


Link to post
Share on other sites

You are using:

_IECreate("www.removed.com", 0, 1, 0)

The 4th parameter is set to 0, which tells _IECreate no to wait at all for the page to load. Your _IELoadWaitTimeout(20000) therefore has no effect. You are therefore trying to retrieve the body text before the document is loaded.

You need to set $f_wait to 1 and then check @error after the _IECreate to see of a timeout error was encountered.

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

Share this post


Link to post
Share on other sites

You are using:

_IECreate("www.removed.com", 0, 1, 0)

The 4th parameter is set to 0, which tells _IECreate no to wait at all for the page to load. Your _IELoadWaitTimeout(20000) therefore has no effect. You are therefore trying to retrieve the body text before the document is loaded.

You need to set $f_wait to 1 and then check @error after the _IECreate to see of a timeout error was encountered.

Dale

Sorry about that. I changed it to make the browser window visible and messed up. Here is the code I used for the latest test.

[/code]
; ************************************************************************
; Script will connect to a web site specified in the command line
; Download the html output to a variable and then convert the information
;between the Body Tags to text
; *************************************************************************
$var1 = 0

    #AutoIt3Wrapper_run_debug_mode=Y

    #include <IE.au3>; Internet explrer include
    #include <file.au3>; File and Directory Operations include
    #NoTrayIcon; Hide tray icon
While $var1 = 0
    _IELoadWaitTimeout(20000); Set IE Timeout to load web page within 20 seconds
    $oIE = _IECreate("www.removed.com", 0, 1, 1); Silently open web page that was provided as command line switch
    $sText = _IEBodyReadText($oIE); convert web site from HTML to Text
    _IEQuit($oIE); close IE window
    $file = FileOpen("c:\temp\ib.txt", 2); Open file to write text to

    If $file = -1 Then; verify that file opens correctly
        Exit; exit script if it does not
    EndIf

    _FileWriteLog($file, $sText); write text to file specified in command line switch number two
    FileClose($file); close text file
    Sleep(120000)
    WEnd[code]

It ran fine for hours but then errored out. Below is what the log showed.

0014: 0-0: _IELoadWaitTimeout(20000); Set IE Timeout to load web page within 20 seconds

0015: 0-0: $oIE = _IECreate("www.removed.com", 0, 1, 1) ; Silently open web page that was provided as command line switch

--> IE.au3 V2.3-1 Warning from function _IELoadWait, $_IEStatus_LoadWaitTimeout

0016: 6-0: $sText = _IEBodyReadText($oIE) ; convert web site from HTML to Text

C:\Program Files\AutoIt3\Include\IE.au3 (2143) : ==> The requested action with this object has failed.:

Return $o_object.document.body.innerText

Return $o_object.document^ ERROR

->22:10:26 AutoIT3.exe ended.rc:1

+>22:10:27 AutoIt3Wrapper Finished

At the same time the visible browser window displayed the error in the attached screen capture.

Share this post


Link to post
Share on other sites

So what did you expect to happen?

You need to check @error after the _IECreate() and take appropriate action if it is anything other than success.

Dale

p.s. the error you show in the screen shot comes from the web server and has nothing to do with IE.au3


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

Share this post


Link to post
Share on other sites

So what did you expect to happen?

You need to check @error after the _IECreate() and take appropriate action if it is anything other than success.

Dale

p.s. the error you show in the screen shot comes from the web server and has nothing to do with IE.au3

I expected that if the web page did not respond within the 20 seconds specified in IELoadWaitTimout that the script would continue running and not terminate with the following error

Warning from function _IELoadWait, $_IEStatus_LoadWaitTimeout

If my logic is flawed please let me know but I expected that once the timeout period was exceeded IECreate would stop trying to load the page and continue through the rest of the script without having to use @error.

Please advise and thank you!

Share this post


Link to post
Share on other sites

It didn't terminate with the warning - it terminated when you tried to read the HTML from a page that didn't exist (the next line). Again, you need to check the value of @error after the the call to _IECreate and NOT ATTEMPT TO READ the HTML if it tells you that _IECreate did not succeed. Look at the helpfile for _IECreate - it will show you the different possible values for @error and their meanings.

You may also want to look at _IEErrorHandlerRegister(). It will prevent COM errors from being fatal, but you will have to carefully check status after function calls.

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

Share this post


Link to post
Share on other sites

It didn't terminate with the warning - it terminated when you tried to read the HTML from a page that didn't exist (the next line). Again, you need to check the value of @error after the the call to _IECreate and NOT ATTEMPT TO READ the HTML if it tells you that _IECreate did not succeed. Look at the helpfile for _IECreate - it will show you the different possible values for @error and their meanings.

You may also want to look at _IEErrorHandlerRegister(). It will prevent COM errors from being fatal, but you will have to carefully check status after function calls.

Dale

Thank You I understand now. Testing updated script now.

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
Sign in to follow this  
Followers 0