2013-06-22 25 views
0

Watin無法使用IE 9捕捉瀏覽器彈出窗口。相反,如果拋出此類彈出窗口,我想跳過它並繼續執行其餘的程序。是否有可能以這種方式跳過?C#Watin - 每當瀏覽器拋出一個彈出窗口(網頁消息)時跳過迭代

彈出窗口是JavaScript彈出窗口。

+1

雖然看起來你的問題可能有足夠的信息讓別人幫助你。你應該包括你所做的任何研究努力 – Sayse

+0

什麼彈出窗口?他們是如何創建的?他們是JS彈出窗口嗎?彈出窗口實際上意味着什麼?如同爲什麼你忽視他們? – Arran

+0

艾倫 - 對不起,我錯過了提前。是的,他們是JS彈出窗口 – user2511409

回答

0

您提到Popup是JS彈出窗口,您不能忽略它們並繼續瀏覽器主窗口亮起,並且控件獲取彈出消息。

,你可以嘗試像

var browser = new IE(); 
var url = "someurl"; 
browser.GoTo(url); 

//一些導航後彈出aapers

//當popupappears控制不會自動返回到的代碼和超時而IE是忙碌異常。

所以我們需要在這裏使用

somebtton.ClickNoWait() //In case of Button Click 

browser.GoToNoWait() // In case of pop up appearing just after navigation. 


      //Finds the alert dialog if it appears 
     AlertDialogHandler AlertDialog = new AlertDialogHandler(); 
     try 
     { 
      //Code for checking if the case number is invalid and a dialog box appears. 
      Settings.AutoStartDialogWatcher = true; 
      Settings.AutoCloseDialogs = true; 

      browser.AddDialogHandler(AlertDialog); 

      AlertDialog.WaitUntilExists(); 

      //If alert dialog is found then close the dialog and log error 
      if (AlertDialog.Exists()) 
      { 

       //Click OK button of the dialog so that dialog gets closed 
       AlertDialog.OKButton.Click(); 
       browser.WaitForComplete(); 
       browser.RemoveDialogHandler(AlertDialog);      

      } 
     } 
     catch 
     { 
       //Removes the dialog handler if the Dialog dosen't appear within 30 secs. 
       browser.RemoveDialogHandler(AlertDialog);    
     } 

試試吧,如果你仍然面臨的問題,顯示像你在做什麼一些代碼。

相關問題