2013-02-19 183 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