Watin嵌入在winform应用程序

问题描述:

我越来越ie即脚本错误,我如何处理在Watin中的对话? 我使用下面的代码,不工作,任何建议,链接,提示..... 也试图禁用脚本调试,但错误没有消失。Watin嵌入在winform应用程序

- >。如何使用Watin做到这一点。

- >。任何其他方法来从winform应用程序执行相同的操作。

var __ie = new WebBrowserIE(webBrowser1); 

var thread = new Thread(() => 
{ 
var helper = new DialogHandlerHelper(); 
using (new UseDialogOnce(__ie.DialogWatcher, helper)) 
     { 
      __ie.GoToNoWait("https://adwords.google.com/o/Targeting/Explorer?__u=1000000000&__c=1000000000&ideaRequestType=KEYWORD_IDEAS#search.none"); 
System.Threading.Thread.Sleep(5000); 
} 

foreach (string item in helper.CandidateDialogHandlers) 
{ 
    //dialog handler to use, but it does not reach here. 
} 

}); 

thread.SetApartmentState(ApartmentState.STA); 
thread.IsBackground = true; 
thread.Start(); 

enter image description here

预先感谢您。

哇,溶液呈easer比它看起来,附着到webrowsercontrol之前华廷,添加

webBrowser1.ScriptErrorsSuppressed = TRUE;

对不起家伙:)

谢谢任何​​方式。

我也有同样的问题,但我不想压制对话框,我想记录他们抛出的错误。

下面的函数应该处理这个问题:

public static String HandleDialog(IE ie) 
    { 
     if (ie.HtmlDialogs.Count > 0) 
     { 
      HtmlDialog dialog = ie.HtmlDialogs.First(); 
      String text = dialog.Text; 
      ie.HtmlDialogs.CloseAll(); 
      return text; 
     } 
     else 
      return ""; 
    } 

我有我的测试报告“带有警告合格”的结果,如果任何脚本失败的最终发生。