Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4231670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:59:53+00:00 2026-05-21T01:59:53+00:00

I am writing automation scripts using WATIR and WATIN. Watir has something called page

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T01:59:54+00:00Added an answer on May 21, 2026 at 1:59 am

    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. IE class:

    class MyIE : IE
    {
        public MyIE(string url) : base(url) { } //TODO: add constructors
    
        public override void WaitForComplete(int waitForCompleteTimeOut)
        {
            base.WaitForComplete(waitForCompleteTimeOut);
            Console.WriteLine("Page has been loaded");
        }
    }
    

    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 Page class from WatiN library. It is well documented. Example for watin.org webpage:

    var ie = new MyIE("http://watin.org/");
    
    var homePage = ie.Page<HomePage>();
    Console.WriteLine(homePage.FirstFeature);
    homePage.DocumentationLink.Click();
    
    var documentationPage = ie.Page<DocumentationPage>();
    Console.WriteLine(documentationPage.FAQLink.Url);
    

    To run that code you need following classes:

    abstract class WatiNBasePage : Page
    {
        [FindBy(Id = "header")]
        public Div HeaderDiv { get; set; }
    
        public Link HomeLink { get { return HeaderDiv.Link(Find.ByText("Home")); } }
    
        public Link DocumentationLink { get { return HeaderDiv.Link(Find.ByText("Documentation")); } }
    
        protected override void InitializeContents()
        {
            base.InitializeContents();
            VerifyDocumentProperties(UnverifiedDocument, errorMessage => { throw new Exception(errorMessage); }); //TODO: modify if needed
        }
    
        protected override void VerifyDocumentProperties(Document document, Page.ErrorReporter errorReporter)
        {
            base.VerifyDocumentProperties(document, errorReporter);
            if (!HomeLink.Exists)
                errorReporter("HomeLink not exists");
            //TODO: more checks here
        }
    }
    
    class HomePage : WatiNBasePage
    {
        [FindBy(Id = "features")]
        public Table FeatureTable { get; set; }
    
        public string FirstFeature { get { return FeatureTable.Span(Find.First()).Text; } }
    }
    
    class DocumentationPage : WatiNBasePage
    {
        [FindBy(Text = "Frequently Asked Questions")]
        public Link FAQLink { get; set; }
    }
    

    Basically you need to implement VerifyDocumentProperties. Above code will check if HomeLink exists, but maybe you would like to check if DocumentationLink exists etc. The second thing is to modify call to VerifyDocumentProperties. Now, if verification fails, Exception will be thrown after calling ie.Page<T>() (where T is a subclass of WatinBaseClass).

    In my opinion, even if you don’t need to use “page checkers”, using Page class 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For writing scripts for process automation in Linux platform, which scripting language will be
I am writing some Internet Explorer automation scripts using PowerShell. Here is how I
I'm writing an application that can run PowerShell scripts which I'd like to be
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I'm writing an automation script on a production server that, among other things, needs
I'm considering writing my own delivery code using PowerShell and/or C#, maybe shelling to
I've writing some Exchange 2010 Unified Messaging automation scripts. I'm trying to automate the
I am writing a Test Automation Framework that involves automating testing a Winforms and
I'm writing an automation script with autoit: http://www.autoitscript.com/autoit3/index.shtml . In the process I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.