2011-07-24 2 views
0

J'essaie de faire fonctionner le code suivant en utilisant à la fois Watin et HttpWatch.Erreur de compilation Watin et HttpWatch?

Je reçois une erreur de compilation de « Le type ou namesapce « IEBrowser » n'a pas pu être trouvée (vous manque une directive ou une référence d'assemblage? En utilisant)

je HttpWatch, Interop.SHDocVw, Watin .Core, et Microsoft.mshtml référencé. Je ne suis pas sûr de ce qui ne va pas?

Le code ci-dessous est ce que je me sers et provient de http://blog.httpwatch.com/2008/10/30/using-httpwatch-with-watin/

je vraiment besoin de Watin et HttpWatch travailler ensemble dans un même projet pour que je puisse surveiller les performances du serveur.

Merci!

using System; 
using System.Collections.Generic; 
using System.Text; 
using WatiN.Core; 

namespace WatiN 
{ 
    class Program 
    { 
     [STAThread] 
     static void Main(string[] args) 
     { 
      // Open a new Internet Explorer window and 
      // goto the google website. 
      IE ie = new IE("http://www.google.com"); 

      // Attach HttpWatch to this new instance of IE 
      HttpWatch.Controller ct = new HttpWatch.Controller(); 

      // the below line was supposedly for Watin 1.3 
      //HttpWatch.Plugin plugin = ct.IE.Attach((SHDocVw.IWebBrowser2)ie.InternetExplorer); 

      // the below line is for Watin 2.x 
      HttpWatch.Plugin plugin = ct.IE.Attach((IEBrowser)ie.NativeBrowser).WebBrowser; 

      // Start recording a log file in HttpWatch 
      plugin.Record(); 

      // Find the search text field and type Watin in it. 
      ie.TextField(Find.ByName("q")).TypeText("WatiN"); 

      // Click the Google search button. 
      ie.Button(Find.ByValue("Google Search")).Click(); 
      ie.WaitForComplete(); 

      // Stop recording and save an HttpWatch log file 
      plugin.Stop(); 
      plugin.Log.Save(@"c:\mydir\googlesearch.hwl"); 

      HttpWatch.Summary logSummary = plugin.Log.Entries.Summary; 

      Console.WriteLine("\r\nElapsed time (secs) = " + logSummary.Time.ToString() + 
           " Downloaded bytes = " + logSummary.BytesReceived.ToString()); 

      // Uncomment the following line if you want to close 
      // Internet Explorer and the console window immediately. 
      //ie.Close(); 
     } 
    } 
} 

Répondre