2011-12-29 6 views
0

私はJavaScriptの単純な検証をテストするために以下のコードを使用しました。
以下はWatiNで使用したコードです。ダイアログボックスのエラーの場合asp.net watin:asp.netでwatinを使用してテストを実行中にエラーが発生しましたか?

[STAThread] 
    static void Main(string[] args) 
    { 
     IE ie = new IE("http://localhost:2034/WebForm3.aspx"); 
     ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize); 
     var confirm = new ConfirmDialogHandler(); 
     ie.AddDialogHandler(confirm); 
     ie.TextField("TextBox1").TypeText("Pa"); 
     ie.Button("Button2").ClickNoWait(); 
     //dialoghandler.WaitUntilExists(5);   
     confirm.OKButton.Click(); 
     var dialoghandler = new AlertDialogHandler(); 
     ie.AddDialogHandler(confirm); 
     **dialoghandler.OKButton.Click();**//the error is could not find dialog does not exist. 
     dialoghandler.WaitUntilExists(10); 
    } 

答えて

0

[OK]をクリックし、あなたがすることによって解決することができます...

ConfirmDialogHandler handler = new ConfirmDialogHandler(); 
using (new UseDialogOnce(ie.DialogWatcher, handler)) 
{ 
    //trigger the event to popup dialogbox 
    ie.Button("Button2").ClickNoWait(); //Copied from your code 
    handler.WaitUntilExists(); 
    handler.OKButton.Click(); 
} 
関連する問題