2013-02-19 177 views
0

你好我与华廷工作,并试图打开URL,但我得到follwoing例外:导航浏览器转到

在WatiN.Core.IE.CreateNewIEAndGoToUri(URI URI,IDialogHandler logonDialogHan dler,布尔createInNewProcess ) WatiN.Core.IE..ctor()at WatinTesting.Program.Main(String [] args) in c:\ users \ admin \ documents \ visua l studio 2010 \ Projects \ WatinTesting \ WatinTesting \ Program。 cs:line 20

该代码早期工作克好。 请让我知道了什么错误:如果请让我知道替代码,我可以使用相同的使用类型:浏览器

的C#代码如下:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using WatiN.Core; 
using WatiN.Core.Native.InternetExplorer; 
using System.Threading; 

namespace WatinTesting 
{ 
    class Program 
    { 

     [STAThread] 
     static void Main(string[] args) 
     { 
      try 
      {    

       IE browser = new IE(); 
        browser.GoTo("http://google.com"); 
        browser.TextField(Find.ByName("q")).TypeText("WatiN"); 
        browser.Button(Find.ByValue("Google Search")).Click(); 

      } 
      catch (Exception e) 
      { 
       Console.WriteLine(e.StackTrace); 
       Thread.Sleep(10000); 
      } 
     } 
    } 
} 

回答

0

请加缺少像watin版本的数据,并且是创建的浏览器实例(IE实例)。

也许这将有助于尝试使用这个参数创建IE实例:

IE ie = new IE("http://www.google.com", true); //first param is url and the second is new process