Jump to content

LoadWait error


Recommended Posts

I am getting this error when I call for the LoadWait function

---------------------------

AutoIt Error

---------------------------

Line 574 (File "C:\Program Files (x86)\AutoIt3\Include\IE.au3"):

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState ^ ERROR

Error: The requested action with this object has failed.

---------------------------

OK

---------------------------

I use the LoadWait quite a bit in my script, and the error occurs intermitedly. The script is providing database support for a database system whose interface runs off of a html interface. The object that I am waiting on is not an IE window, but a frame within an IE window, so I am waiting for the frame to fully load. There are tens of thousands of records I have to run through, so I set this script to run un-attended.

The call I am using is

"_IELoadWait($oFrame10,75)"

I have used this code for about a year, but I am just now running into this being a problem. I used to run for hours on end; now it may run 10 minutes one time, maybe only 2 another, still others it may run 30 minutes. I don't think I have had it run more than 30 minutes in the past week or so.

Any ideas on why I am getting this error?

rp

Link to comment
Share on other sites

i would try to re attach before change on page take place to see if it solve problem and whud get rid of ,75 parametar to see if it help

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Thanks for the reply.

By reattach, do you mean put the code

$oFrame10 = _IEFrameGetCollection($oIE, 10)

after sending the "next" command, but before the LoadWait?

The "next" command is whatever commnad I have to send to get it to load the next "panel" (I am assuming "panel" is the same thing you refer to as "page"). Depending on the form on any specific "panel", the command I have to send may be different.

I use the LoadWait function a lot because I had a bunch of trouble at first to get the script to stay running because the response from the html interface was inconsistent. I tried a lot of things, starting LoadWait for the IE object "_IELoadWait($oIE)", but that didn't help. I tried using it on $oFrame10 and it worked, but occasionally had trouble; I assume AutoIt ran so fast that it would get past the LoadWait before the panel even knew it was changing; hence the ", 75" parameter. With both calling the LoadWait on the Frame Object and the 75 ms delay before running the LoadWait, I had great success. Until lately, that is.

If I eliminate the "75" parameter it hangs up nearly every time. There doesn't seem to be much difference if I change the "75" to "150", though. It seems some delay is needed, but the difference between 75 and 150 is not important.

rp

Link to comment
Share on other sites

with reattach i mean _IEAttach()

i don't know what are you using to send data and how you redirect to another page before using _IELoadWait($oIE)

but if you're sending your data with send() command and submiting page with "{ENTER}" mouse click or some other form that don't include _IE* funcs then i can see the problem with the end result on error for _IELoadWait()

so it would be nice if you can tell what is the *sending the "next" command*? and to try to _IEAttach()

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I have used this code for about a year, but I am just now running into this being a problem. I used to run for hours on end; now it may run 10 minutes one time, maybe only 2 another, still others it may run 30 minutes. I don't think I have had it run more than 30 minutes in the past week or so.

Any ideas on why I am getting this error?

Have you updated anything recently or made any other changes that you know of? New version of IE or Windows? Are these Intranet or Internet pages?

Link to comment
Share on other sites

To send data, I use _IEFormElementSetValue($oFormElement, $sValue). I used to just tab to the input box, but that was not very reliable. Using _IEFormElementSetValue() works much better.

To send the "next" command I use _IEAction(_IEGetObjByID($oFrame10,"next"),"click") on pages where the send command is issued by clicking the "next" button. On some pages, I have to use Send("{Enter}") command, but I have found that using the _IEAction() works much better when it is available. There are a few screens where I have to use the Send("{Enter}") command, though.

The issue does not seem to be very repeatable, however, and it may just be an issue with the intranet I am using. I didn't have any problems this morning, for example, but when I set it to run during lunch, it created the above error about 5 minutes after I left. When I got back after lunch, I added the _IEAttach() right after the _IEAction() command and it hasn't generated the error since (although since the script can't run in the background, I have only let it run for about 30 minutes at a time). Anyway, I'll see if this fixes it and report back in a day or two, since by then I should know.

And, to Mr MItchell, this is running over a local Intranet and I have not made any changes that I know of. Of course, our IT department will go in and change my boot file and make a bunch of other changes that I woulndn't understand even if they told me, so I just hope the problem isn't there.

rp

Link to comment
Share on other sites

OK. No need to wait for a day or two to report. I added the _IEAttach() command immediately after any place I had a _IEAction() or a Send("{Enter}") command. First time it created the above error in about 2 minutes. Second time, it was the same LoadWait() command that generated the error, but instead of Line 574, it was Line 585 in the LoadWait() script, after about 10 minutes. I started again and it ran about 15 minutes until I got the Line 574 error, again. It takes about 4 to 5 seconds to loop through the routine, so it works for literally hunderds of iterations before it runs into an error.

I am still thinking a connection problem with the intranet. I just found out minutes ago that they were having phone problems at the main office. I am not positive, but I think that is where the server is, so maybe it really is just a connecton problem. Would that make sense?

rp

Link to comment
Share on other sites

You could give this a try... replace your _IECreate() functions with

$oIE = ObjCreate("{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
_IENavigate($oIE, $site)
$oIE.visible = 1

Looks like what is happening to you may be the same thing that happened in this When you create an IE window using _IECreate() but navigate to an Intranet location you lose the handle on the IE Object because it creates a new process prior to navigation - IE uses different security settings for Intranet. I haven't seen your script, but that might be why you have to use _IEAttach() to get it back. This ObjCreate above creates the IE process with the Intranet security settings so that when you navigate to an Intranet site it will use the existing process and you shouldn't lose your handle on it.

.

Link to comment
Share on other sites

Thanks, MrMitchell. If nothing else, reading the thread referenced in your post convinced me that I must be doing something right. It seems the OP of that thread is trying to do something very simialr to what I am doing (and has even found some of the same solutions).

But, I don't use _IECreate() or _IENavigate() functions. I start with the explorer window already open and to the intranet site I am working with. This site is secured with a username and passowrd that, while easy to program with Autoit, the script is intended to be used by several different users and they will have to navigate through the security on their own prior to running the script. At least, that is how I have it set-up now. I just attach to the open instance of Explorer and go. All navigation is performed by the site's HTML and the script only inputs to forms that exist is the various Frames. So, the LoadWait is acting on a Frame Object (not an Explorer Object), since I have to wait for the frame to fully load before the srcipt can continue. At least, that is my understanding of what I am doing. I really don't know, as I don't know HTML nor do I have access to the HTML code (I only found the Frames and how to use the form(s) in the Frames by trial and error; many trials and a lot of error).

So, I am not sure how to even try your suggestion. I was told this morning that they did, in fact, have server problems that are corrected, now. I will try again and see (hope) if those were the source of my problem.

Thanks, again.

rp

Link to comment
Share on other sites

  • 3 weeks later...

OK, the suggestion from MrMitchell did no good. I still have the problem, and it is quickly becoming a real big issue for me.

I re-wrote my scripts so that instead of just attaching to an open instance of IE already linked to the intranet page I need, I created a new IE object using

$oIE = ObjCreate("{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")

and navigating through the password pages to get to where I need to be.

It doesn't seem to make any difference.

In summary,

I have a script that runs through a form in a frame on an intranet page. On each iteration, it inputs a new value into a frame input and uses _IEAction($oNext,"click").

After the "click" I have _IELoadWait($oFrame10,150) to give the frame time to refresh, then it copies the text and pulls out what in need and adds it to a matrix.

This runs just fine. In the past, it has run for hours. Now, however, it will run for dozens to hundreds of iterations then comes up with

---------------------------

AutoIt Error

---------------------------

Line 574 (File "C:\Program Files (x86)\AutoIt3\Include\IE.au3"):

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState ^ ERROR

Error: The requested action with this object has failed.

---------------------------

OK

---------------------------

I really need to find a way around this, since I will be needing these scripts to run overnight, unattended, and not crash 10 minutes into the run.

Thanks,

redpicker

Link to comment
Share on other sites

---------------------------

AutoIt Error

---------------------------

Line 574 (File "C:\Program Files (x86)\AutoIt3\Include\IE.au3"):

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState ^ ERROR

Error: The requested action with this object has failed.

According to MSDN http://msdn.microsoft.com/en-us/library/ie/ms534359%28v=vs.85%29.aspx

document.readyState is a string value one of the following values

  • uninitialized
  • loading
  • loaded
  • interactive
  • complete

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

OK, I'm getting in way over my head with this, but I think this might work.

Instead of calling _IELoadWait($oFrame10,150), I replace that line with

Sleep(150)
While Not(String($oFrame10.document.readystate)="complete")
Sleep(100)
WEnd

In my specific application, the object is always a frame object ($oFrame10, to be exact), and the script is always running in a HTML environment(?). If it generates an error, I need to know about it, so I think this will do it.

It seems that is all the UDF function is doing in my case. That is, I am passing parameters $o_object = "$oFrame10" and $i_delay = "150" and $i_timeout is staying at -1. If I understand what Bowmore and MrMitchell posts are trying to say, in HTML, the readystate property is a text string and "complete" is what the UDF is looking for. For C/C+, the property is an integer equal to 4 for complete. The UDF is written so that a page running either HTML or C/C+ will work. But, in this case, it appears that I am getting some problems testing the readystate property for an integer result. Am I making any sense?

Anyway, using the above instead of _IELoadWait works without hangup (I think, I have to let it run for a while, now). It does run quite a bit faster.

Would this do the same thing?

Sleep(150)
While String($oFrame10.document.readystate) <> "complete"
Sleep(100)
WEnd

Thanks for the hints,

redpicker

Link to comment
Share on other sites

The UDF is written so that a page running either HTML or C/C+ will work. But, in this case, it appears that I am getting some problems testing the readystate property for an integer result. Am I making any sense?

The page won't run C/C+...I simply provided that link because the return on the readyState property as used in this function is a enum... it returns a value of 0,1,2,3 or 4 and each of those values corresponds to a status.

The biggest issue here is that's we're all having trouble understanding your problem from what you're providing.

When you run:

_IELoadWait($oFrame10,150)

and get:

Line 574 (File "C:\Program Files (x86)\AutoIt3\Include\IE.au3"):
While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)
While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState ^ ERROR
Error: The requested action with this object has failed.

It's likely because the object (frame) you passed to the_IELoadWait() function isn't an object anymore - or at least not an object that supports the readyState property. We need to know how that frame you're working with works internally; i.e. Need to see some HTML, a video of you using it, something, anything, etc...

Maybe every time you click "next" the frame is destroyed and a new one is created. If that happens you have to use _IEAttach() to get a new handle on it, every time you click next.

Edit: Had to fix second code box

Edited by MrMitchell
Link to comment
Share on other sites

Unfortunately, I do not have access to the HTML code. If I did, I wouldn't be in this mess since I could just accomplish my goal by modifiying the existing code. That's a whole 'nother story.

This error does not happen every time i click "next". Not even once in ten times. It is very random. Sometimes it will happen the second time (I don't think I've run it happening on the first iteration, but maybe it has). Other times it will loop through the same commands literally hundreds of times with no problem. Just when I think I've got it, BAM!, the error pops up.

It is acting like Autoit is occasionally out-running itself.

For example, to employ your _IECreate solution, I start with the following code

$oIE = ObjCreate("{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
_IENavigate($oIE, "[url="http://houston2/mwp"]http://CompanySite/grt[/url]")
$oIE.visible = 1
winwaitactive("CompanySiteName")
$oFrame2 = _IEFrameGetCollection($oIE, 2)

The window with the name "CompanySiteName" does not appear until after login is completed. Frame2 only exists in the window with the name "CompanySiteName"; the login window has a different name and does not have any frames in it.

The WinWaitActive command is there to stop the script so the user can login. It works just fine for this. Most of the time. Every once in a while, maybe one in 10 launches, before I login, I get an Autoit Error saying that it could not work with the $oFrame2 object. Now, this is before I have even logged in, so Autoit should not have even gotten to any commands that refer to $oFrame2 at this point.

I don't see why.

Link to comment
Share on other sites

Are you using IE? Install DebugBar, it call tell you all kinds of things about your IE objects that you might want to know.

All I can say now it just put a ton of error checking in your script, to help you track down the issue. I'm talking record line numbers and return values and whatever you can do.

Link to comment
Share on other sites

Line 574 (File "C:\Program Files (x86)\AutoIt3\Include\IE.au3"):
While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)
While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState ^ ERROR
Error: The requested action with this object has failed.

It's likely because the object (frame) you passed to the_IELoadWait() function isn't an object anymore - or at least not an object that supports the readyState property.

In the Error message above $o_object.document.readyState has already been successfully evaluated in the line (see below) as the first statement before the OR and is failing when it is evaluated the second time after the OR. It may be as you say, that the page has changed, but I don't think there will be more than a few milliseconds between the 2 evaluations of $o_object.document.readyState

While Not (String($o_object.document.readyState) = "complete" Or $o_object.document.readyState = 4 Or $f_Abort)[font='Helvetica Neue',Arial,Verdana,sans-serif]
Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Any chance you can post at least a screenshot of the frame/window you're working with?

What is this software you are using to interact with the database, is it in-house proprietary stuff or something commercially available?

Do you have the ability to read/write the database directly yourself?

Edit: Add 1 more thing... for your _IELoadWait() are you checking the return and/or @error value to make sure it's actually returning because the page/window/frame is fully loaded or might it actually be timing out because it never finishes loading or takes longer than 5 minutes to load?

Edited by MrMitchell
Link to comment
Share on other sites

Unfortunately, I do not want to post a screenshot as it would both identify my company but also the producer of the software I am working witn. It is a canned system that has been customized for our company by the producer of the software. This is an MRP system for a large manufacturing facility that handles production, finance, scheduling, etc... A tangentially related, but not insignifigant issue is that the company is actively persuing a new MRP system (for a variety of reasons, my issue not being one of them), so both our IT department and the software producer are not interested in supporting a product that will be dumped soon.

Yes, the software is used to interact with the database. I do not have read/write access to the database except through this IE-based interface. In a previous life, I could accomplish my goals using MS-Word macros that would interface with the MRP system the previous company was using. That doesn't work here. I tried using VB, but since MS programs don't work and play well with other programs (heck, they have issues palying with themselves), I looked around and found Autoit.

I am a mechanical engineer. I am responsible for maintaining all the part numbers (tens of thousands). I have little programing training (I learned BASIC and FORTRAN in college; that was in the '70s). But, I was able to hack out some scripts that would take a list of part numbers (thousands of them) and make the needed changes through the interface, one by one. It was slow and crashed a lot, but when I found out how to make _IELoadWait work on the frame I was working in, it would run for hours, so I could start it at 6 PM and by 8 AM, it would have maybe half of them done. A few days of this and I was set.

Up until recently. My guess is they have changed the programming behind the interface, but I have no hope of finding out what.

The only way I see out of this is if I can trap the AutoIT error. That is, if the $o_object.document.readyState action fails, is there a way to get AutoIT to wait 100 ms and try it again instead of halting the program and putting up the message box?

Link to comment
Share on other sites

One addtional bit of informaiton that may or may not be of any importance at all, but in fooling around with trying to find a way to trap this error, I did discover that the interface was written for InernetExplorer5 and I am running IE8 (the $o_object.document.documentMode property is "5"). I don't know if that is relevant or not.

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