I have the following code snippet from a test, my intention is to either wait for a ReadyState complete OR exit after 8 cycles through the loop. I came in this morning (after running it all night) and find the code worked for over 100 iterations but was looping infinitely. theCount was almost 1.4 million, I'm not sure what the ReadyState was. My question is how could this happen?
<font class="small">Code:</font><hr /><pre> On Error Resume Next
Do until BrowserPage.Object.links(i_Link).ReadyState = "complete" or theCount > 8
theCount = theCount +1
Turbo - Yes I tested the code (extensively) and like I said there were about 100 successful iterations, and the On Error was put in because occasionally the page was slow to load and the link wouldn't exist and a "Object required" error would be thrown. I thought I'd have it iterate a few times and the page would finish loading and all would be well which was the case many times. What threw me is that it continued to loop ad infinitum despite the fact that theCount more than satisfied the exit criteria.
I do sync the browser and the page and they return ok prior to this step, but on rare occasion the link wouldn't exist yet. When the error would pop up I would click "Retry" and it would carry on fine, this code was an attempt to eliminate that hand holding.
Well, I tried the theory out on some sample code and it appears to evaluate both condition regardless of whether the first qualifies for exit. I recall a code language where once a condition was satisfied any subsequent conditions were not evaluated (C++?), but not the case I guess for QTP/VBScript, so the same issue remains.. [img]/images/graemlins/frown.gif[/img] I will find some other way though!