Watin 和 HttpWatch 编译错误?

发布于 2024-11-25 14:13:48 字数 2180 浏览 4 评论 0原文

我正在尝试使用 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();
        }
    }
}

I'm trying to get the following code to work using both Watin and HttpWatch.

I'm getting a compile error of 'The type or namesapce 'IEBrowser' could not be found (are you missing a using directive or an assembly reference?)

I have HttpWatch, Interop.SHDocVw, WatiN.Core, and Microsoft.mshtml referenced. I'm not sure what else is wrong?

The below code is what I'm using and was taken from http://blog.httpwatch.com/2008/10/30/using-httpwatch-with-watin/

I really need to get Watin and HttpWatch working together in same project so I can monitor server performance.

Thanks!

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自我难过 2024-12-02 14:13:48

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

HttpWatch now comes with a sample program showing you how to use WatiN 2.1 with HttpWatch:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文