Friday, July 31, 2009

How to test for dialog boxes using watin

Note need to add a using for (?) watin.core.dialoghandlers

[Test]
public void Default_PressEnterWithoutSearchTerm_NoDialogDisplayed()
{
using (var browser = new IE())
{
var dialogHandler = new AlertAndConfirmDialogHandler();
browser.DialogWatcher.Add(dialogHandler);

browser.GoTo(_url);
browser.WaitForComplete();

browser.Button(Find.ById(homeSubmitID)).Click();
Assert.AreEqual(0, dialogHandler.Count);
browser.WaitForComplete();
}
}

This asserts for no dialog box (a bad negative test) but could be changed to assert >1 dialogs or even on the dialog message.

1 comment:

  1. A press size of a hundred and twenty tons would ready to|be succesful of|have the power to} accommodate your plastic injection molded product. Electric injection molding machines use servo motors to manage injection and clamping forces. Surplex.com is an online auctioneer specialising in used equipment for metalworking and woodworking. While we may not have the perfect injection moulding machine for your organisation proper now, we are constantly sourcing new precision machining tools from liquidation gross sales and firms upgrading their present production traces.

    ReplyDelete