Determining When a Web Application is Fully Loaded into IE

When performing Web application UI testing using Windows PowerShell, as I described in my last blog entry, the trickiest task is to determine when the Web application under test is fully loaded into Internet Explorer. You can’t realistically use a crude approach such as:
$ie = new-object -com "InternetExplorer.Application"
because there’s really no way to predict how long the app will take to load, or even if the app will load at all. There are several alternatives you can use. One is to use the InternetExplorer DocumentComplete event. This approach is a bit tricky and I personally prefer to avoid using event techniques when performing script-based automation. Another approach is the use the InternetExplorer readyState property. This approach is great in principle but there are just enough minor annoyances with the technique for me to avoid it in general. A third approach, and the one I use most often, is to use a delay loop where the loop will exit if a user control reference is accessible (meaning not null). The loop condition must also exit if the number of delays exceeds some threshold value so that you avoid an infinite loop situation. I am currently writing up the details of this approach for an MSDN Magazine "Test Run" column and I’ll be submitting it to the new MSDN Editor-in-Chief, Howard Dierking, within a week or so. 
This entry was posted in Software Test Automation. Bookmark the permalink.