|
4#
楼主 |
发表于 2007-1-15 11:54:38
|
只看该作者
[Test]
public void ConfirmDialogHandlerOK()
{
using(IE ie = new IE(TestEventsURI))
{
ConfirmDialogHandler confirmDialogHandler = new ConfirmDialogHandler();
using(new UseDialogOnce(ie.DialogWatcher, confirmDialogHandler))
{
ie.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
confirmDialogHandler.WaitUntilExists();
Assert.AreEqual("Do you want to do xyz?", confirmDialogHandler.Message);
confirmDialogHandler.OKButton.Click();
ie.WaitForComplete();
Assert.AreEqual("OK", ie.TextField("ReportConfirmResult").Text, "OK button expected.");
}
}
}
public class UseDialogOnce : IDisposable
{
private DialogWatcher dialogWatcher;
private IDialogHandler dialogHandler;
public UseDialogOnce(DialogWatcher dialogWatcher, IDialogHandler dialogHandler)
{
this.dialogWatcher = dialogWatcher;
this.dialogHandler = dialogHandler;
dialogWatcher.Add(dialogHandler);
}
#region IDisposable Members
public void Dispose()
{
dialogWatcher.Remove(dialogHandler);
dialogWatcher = null;
dialogHandler = null;
}
#endregion
} |
|