I am writing automation scripts using WATIR and WATIN. Watir has something called page checkers, which are code snippets that run on each page load. Is there something similar in WATIN ? I want a piece of code to run on each page load. Generally this is used to check for page errors or page loading images.
I am writing automation scripts using WATIR and WATIN. Watir has something called page
Share
It is not really that easy to tell when page loads. I quickly googled about that page checkers in Watir, that you mentioned and found an article about page checkers in Watir. See first comment bellow the article. AFAIK it’s really similar in WatiN.
Unfortunately, I don’t see any similar functionality in WatiN (no event is fired after internal call to
WaitForComplete. The easiest thing you could do is to subclass eg.IEclass:However, the situation will be similar to described in mentioned comment (runs a lot more regularly than just page load).
I think that better approach would be using
Pageclass from WatiN library. It is well documented. Example for watin.org webpage:To run that code you need following classes:
Basically you need to implement
VerifyDocumentProperties. Above code will check ifHomeLinkexists, but maybe you would like to check ifDocumentationLinkexists etc. The second thing is to modify call toVerifyDocumentProperties. Now, if verification fails,Exceptionwill be thrown after callingie.Page<T>()(where T is a subclass of WatinBaseClass).In my opinion, even if you don’t need to use “page checkers”, using
Pageclass is still really useful and clarifies the code, so I really recommend using it. I regret that I haven’t discovered it when I was starting work with WatiN.