또 다른 옵션으로 AlertAndConfirmDialogHandler를 사용할 수 있습니다. 이 핸들러는 모든 경고를 닫거나 팝업 대화 상자를 확인하지만 먼저 대화 상자에 표시된 텍스트를 가져 와서 저장합니다. 이 경고 문자열 배열을 검사하여 개수가 0인지 확인할 수 있습니다. 테스트 수업의 Teardown 또는 FixtureTeardown에서이 작업을 수행 할 수 있습니다. 이 핸들러를 사용하는 방법을 표시하는 WatiN 유닛 테스트에서 테스트의 복사본을 다음
는
:
[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");
}
이것은 또한 나를 자동 종료 동작은 더 플러그 수 있도록 트리거합니다. 대화 상자를 자동으로 닫는 대신 다른 핸들러가 대화 상자를 처리 할 수없는 경우 호출 할 대화 상자 핸들러를 등록 할 수 있다면 좋을 것입니다.
HTH 제론 반 Menen 리드 dev에 WatiN 내가이 방법으로 문제를 직면하고
, 그것은 언젠가 작동하고 때로는하지 않습니다. – rahoolm