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

Related Questions

Whenever I run this, and open the color dialog, there are many colors that
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters
I want to use a autocomplete combobox http://jqueryui.com/demos/autocomplete/#combobox within a modal dialog. However whenever
I have a JavaScript pop-up dialog that appears whenever a user calls a specific
This is pretty confusing. I'm receiving this error whenever I try to add to
Whenever I use the signal/slot editor dialog box, I have to choose from the
I'm creating a dialogbox with a picture control and whenever I initialize the dialog
Whenever I design a database, I always wonder if there is a best way
Whenever I try to add a new project to my SourceSafe repository it creates
Whenever a application needs internet and connection fails, I get a message dialog Connection

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.