Jump to content

Recommended Posts

Posted

I'm automating a form submission process that involves multiple pages of forms. I need to detect when a page unloads so that it can start waiting for the next one to load.

I tried detecting whether an object no long exists, like so:

Do
    Local $frame = _IEFrameGetObjByName($oIE, "framename")
Until IsObj($frame) = 0

But that either gives me an error during transition or the next page has the same element so it never returns 0.

Since each form has a different loading time, I don't want to just slap Sleep() at the beginning hoping the next page will start to load by then. Is there a way to detect a page unload or some other workaround?

Posted

When I submit a form it takes some time before starting to load the next page. I need to wait for the next page to begin loading before using _IELoadWait(), but that could take anywhere from a few milliseconds to several seconds.

Posted (edited)

I've had moderate success by getting a frame's HTML code and repeatedly setting another variable to get the HTML code until it returns something else, like so:

Func LoadWait()
   $Compare1 = $oFrame.document.documentElement.outerHTML
   Do
      $Compare2 = $oFrame.document.documentElement.outerHTML
      Sleep(200)
   Until $Compare1 <> $Compare2
EndFunc

It works 80% of the time, but there's apparently a window of time where $oFrame is undefined and I get an error. I've read that @error can be used to avoid crashing when encountering an error, but I can't seem to get it to work. Help would be much appreciated.

Edited by gander

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
×
×
  • Create New...