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 198529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:56:43+00:00 2026-05-11T16:56:43+00:00

Whenever a dialog appears and there is no attached handler, watin auto closes the

  • 0

Whenever a dialog appears and there is no attached handler, watin auto closes the dialog. This is helpful when you don’t want to add code for different/several simple confirmations the application might have.

The issue is that using this default behavior can cause simple issues to go unnoticed, like a confirmation dialog appearing in the scenarios it shouldn’t.

I am looking for a simple way to gracefully fail the tests when unhandled dialogs appear. With gracefully I mean the test stops right when the dialog appears with an exception, that gives a decent message that lets you know it was an unexpected dialog error.

  • 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-11T16:56:43+00:00Added an answer on May 11, 2026 at 4:56 pm

    Another option could be to use the AlertAndConfirmDialogHandler. This handler does close every alert or confirm dialog that popups up but first it gets the text shown by the dialog and stores it. You can inspect this Alerts string array and see if the Count is zero. You could do this in the Teardown or FixtureTeardown of the test class.

    Following a copy of a test from the WatiN unittest to show you how you can use this handler:

            [Test]
        public void AlertAndConfirmDialogHandler()
        {
            DialogWatcher dialogWatcher;
    
            Assert.AreEqual(0, Ie.DialogWatcher.Count, "DialogWatcher count should be zero before test");
    
            // Create handler for Alert and confirm dialogs and register it.
            var dialogHandler = new AlertAndConfirmDialogHandler();
            using (new UseDialogOnce(Ie.DialogWatcher, dialogHandler))
            {
                Assert.AreEqual(0, dialogHandler.Count);
    
                Ie.Button("helloid").Click();
    
                Assert.AreEqual(1, dialogHandler.Count);
                Assert.AreEqual("hello", dialogHandler.Alerts[0]);
    
                // remove the alert text from the queue by using Pop
                Assert.AreEqual("hello", dialogHandler.Pop());
    
                Assert.AreEqual(0, dialogHandler.Count);
    
                // Clear the queue
                Ie.Button("helloid").Click();
    
                Assert.AreEqual(1, dialogHandler.Count);
    
                dialogHandler.Clear();
    
                Assert.AreEqual(0, dialogHandler.Count);
    
                dialogWatcher = Ie.DialogWatcher;
            }
    
            Assert.AreEqual(0, dialogWatcher.Count, "DialogWatcher count should be zero after test");
        }
    

    This also triggers me to make the AutoClose behavior more pluggable. It would be nice if one could register a dialoghandler that will be called if no other handlers can handle a dialog, instead of just auto closing the dialogs.

    HTH
    Jeroen van Menen
    lead dev WatiN

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

Sidebar

Ask A Question

Stats

  • Questions 246k
  • Answers 246k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since declarative_base and zzzeek code does not work with sqlalchemy… May 13, 2026 at 8:27 am
  • Editorial Team
    Editorial Team added an answer The Wikipedia page on BMH has an implementation. I think… May 13, 2026 at 8:27 am
  • Editorial Team
    Editorial Team added an answer If the order of alerts matters, use this: for (let… May 13, 2026 at 8:27 am

Related Questions

We're writing a Windows client application in VB.NET. On the first launch of the
I'm a bit newbieish when it comes to the deeper parts of OSX configuration
can't believe I am losing so much time on this one. I have an
I have a simple C++ DLL that implements a few custom actions for a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.