gander Posted January 17, 2013 Share Posted January 17, 2013 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? Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2013 Share Posted January 17, 2013 Anything wrong with waiting for the next page to load? _IELoadWait() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
gander Posted January 17, 2013 Author Share Posted January 17, 2013 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. Link to comment Share on other sites More sharing options...
gander Posted January 17, 2013 Author Share Posted January 17, 2013 (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 January 17, 2013 by gander Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now