We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely?
views:
930answers:
5Hi Glenn,
The time Watin waits is controlled by the WaitForLoadTimeout property. Here's a blog post which talks a little bit about it:
@Cory: Unfortunately it's not that WatiN isn't waiting long enough, it's that it waits until the page loads before it does anything.
We found the solution, load the page with ClickNoWait()
Then look for the link on the page as normal, but call WaitUntilExists()
on the link before calling Click()
. This way WatiN will click the link as soon as it is loaded, not wait until the whole page is loaded.
Here's the code we found to work:
IE browser = new IE(....);
browser.Button("SlowPageLoadingButton").ClickNoWait();
Link continueLink = browser.Link(Find.ByText("linktext"));
continueLink.WaitUntilExists();
continueLink.Click();
@Glenn I was thinking that you would lower the wait time using that, not that the page wasn't waiting long enough. Your way seems much more elegant.
Hi Glenn,
You should be able to leave out the call to WaitUntilExists() since WatiN does this internally when you call a method or property on an element (like the link.Click() in you rexample).
HTH, Jeroen van Menen Lead dev WatiN