Another option would be to use AlertAndConfirmDialogHandler. This handler closes every warning or confirmation dialog that appears, but first it receives the text displayed by the dialog and saves it. You can check this array of warning lines and see if the graph is zero. This can be done in Teardown or FixtureTeardown test class mode.
After a copy of the test from Unitest WatiN, 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");
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]);
Assert.AreEqual("hello", dialogHandler.Pop());
Assert.AreEqual(0, dialogHandler.Count);
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");
}
AutoClose . , , , , .
Jeroen van Menen