【问题标题】:Watin and HttpWatch Compile Error?Watin 和 HttpWatch 编译错误?
【发布时间】:2011-10-12 00:30:40
【问题描述】:

我正在尝试让以下代码同时使用 Watin 和 HttpWatch。

我收到“找不到类型或名称空间 'IEBrowser'”的编译错误(您是否缺少 using 指令或程序集引用?)

我引用了 HttpWatch、Interop.SHDocVw、WatiN.Core 和 Microsoft.mshtml。我不确定还有什么问题?

下面的代码是我正在使用的,取自http://blog.httpwatch.com/2008/10/30/using-httpwatch-with-watin/

我真的需要让 Watin 和 HttpWatch 在同一个项目中一起工作,这样我才能监控服务器性能。

谢谢!

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();
        }
    }
}

【问题讨论】:

    标签: watin httpwatch


    【解决方案1】:

    HttpWatch 现在附带一个示例程序,向您展示如何将 WatiN 2.1 与 HttpWatch 一起使用:

    http://blog.httpwatch.com/2012/06/25/using-httpwatch-and-watin-2-1/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 2012-10-12
      • 2018-02-01
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多