Issue with new feature for IE in WatiN 2.0 Final
In the final release 2.0 of WatiN the new feature for Internet Explorer was announced:
"WatiN will now wait for IE and the DOM Document to get to the ‘interactive’ or ‘ready’ state to avoid unnecessary time-outs"
开发者_开发问答In fact, in my project we need to use old functionality for existed tests, when WatiN waits only 'ready' state(as I understand it is fully loading of the web page). For now, the many tests are failed.
The main problem is that WatiN try to find and to manipulate elements that aren't loaded yet after some action(for example, click on the button)
Is it possible to switch new version of WatiN to old work principle?
Try this extension method
public static void WaitForReady(this Browser browser)
{
int timeWaitedInMilliseconds = 0;
var maxWaitTimeInMilliseconds = Settings.WaitForCompleteTimeOut * 1000;
while (browser.Eval("document.readyState") != "complete" && timeWaitedInMilliseconds < maxWaitTimeInMilliseconds)
{
Thread.Sleep(Settings.SleepTime);
timeWaitedInMilliseconds += Settings.SleepTime;
}
}
I believe I'm having the same issue. The speed improvements in the new Watin, though, are fantastic!
Loading a page and executing something like
foreach(TextField t in browser.TextFields) {
t.setAttribute("value","test");
}
Gives me a system unauthorized exception with the new Watin about 1/10 times. When this happens browser.text
returns ""
so I'm thinking of playing with something like
while(browser.text=="") {
System.Thread.Thread.Sleep(500);
}
(with a break in case the page actually has no text).
精彩评论