Httpwatch是一款强大的网页数据分析工具,它可以在不改变浏览器和网络设置的基础上捕捉http和https数据。查看底层的http数据,包括headers, cookies, cache等,同时统计发送接收请求时间,并提供完备的日志记录系统。同时该工具具有完备的COM接口,用于给用户通过编程的方式操纵httpwatch.

Httpwatch 自动化对象介绍:

Controller 类:总是控制的起点,它用于创建httpwatch插件接口或读取log文件,通过IE属性和Firefox属性的new()方法或者Attach()方法返回Plugin实例对象。

Plugin 类:是httpwatch与浏览器交互的接口。提供了方法用于开始和停止http流量的记录,还有很多方法和属性管理httpwatch的日志文件和配置自动化记录。

Log 类: Plugin对象的Log属性是Log对象的入口。包含了一系列通过httpwatch记录的日志。Log对象中具有很多重要的类,比如Pages, Entries类。

Entry 类: 每个Log对象都包含一组Entry对象,它代表的是单个HTTP事务的详情(比如http请求)

通过 WatiN和httpwatch结合进行自动化测试,可以很大程度扩展自动化测试的范围,比如在自动化测试过程中验证链接的连通性,网页传输速率和时间,查看网页的详细信息等。

C#操作httpwatch

  1. 添加httpwatch自动化类库到项目中
  2. 创建与httpwatch工具的联系

    创建新的IE接口:顶部添加引用  using HttpWatch;

             Controller control = new Controller();
Plugin plugin = control.IE.New();

    创建新的Firefox接口:

             Controller control = new Controller();
Plugin plugin = control.Firefox.New();

    附加一个已存在的IE窗口:

             SHDocVw.IWebBrowser2 ieBrowser = new SHDocVw.InternetExplorer();
ieBrowser.Visible = true; //Required to see new window
Controller control = new Controller();
Plugin plugin = control.IE.Attach(ieBrowser);

    附加一个已存在的Firefox窗口:

             Controller control = new Controller();
Plugin plugin = control.Firefox.Attach(firefoxBrowser);

  3. 通过接口读取http详细信息

Example:

         public static HttpWatchInfo RunHttpWatch(string url)
{
Controller control = new Controller();
Plugin plugin = control.IE.New(); plugin.Log.EnableFilter(false);
plugin.Record();
plugin.GotoURL(url);
control.Wait(plugin, -);
plugin.Stop(); HttpWatchInfo httpWatchSummary = new HttpWatchInfo();
if (plugin.Log.Pages.Count != )
{
Summary summary = plugin.Log.Pages[].Entries.Summary;
httpWatchSummary.URL = url;
httpWatchSummary.Time = summary.Time;
httpWatchSummary.RoundTrips = summary.RoundTrips;
httpWatchSummary.BytesReceived = summary.BytesReceived;
httpWatchSummary.BytesSent = summary.BytesSent;
httpWatchSummary.CompressionSavedBytes = summary.CompressionSavedBytes; IList<string> codes = new List<string>();
for (int i = ; i < summary.StatusCodes.Count; i++)
codes.Add(summary.StatusCodes[i].Result);
httpWatchSummary.StatusCode = codes; IList<HttpWatchDetail> httpWatchDetail = new List<HttpWatchDetail>();
for (int i = ; i < plugin.Log.Entries.Count; i++)
{
HttpWatchDetail detail = new HttpWatchDetail();
detail.URL = plugin.Log.Entries[i].URL;
detail.Result = plugin.Log.Entries[i].Result;
detail.Time = plugin.Log.Entries[i].Time.ToString();
detail.Error = plugin.Log.Entries[i].Error;
try
{
detail.Content = plugin.Log.Entries[i].Content.Data;
}
catch
{
detail.Content = null;
}
httpWatchDetail.Add(detail);
}
httpWatchSummary.Details = httpWatchDetail;
}
plugin.CloseBrowser();
return httpWatchSummary;
}

WatiN和HttpWatch交互简介的更多相关文章

  1. HttpWatch工具简介及使用技巧(转载)

    一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...

  2. HttpWatch工具简介及使用技巧

    一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...

  3. 『计算机视觉』Mask-RCNN_推断网络其二:基于ReNet101的FPN共享网络暨TensorFlow和Keras交互简介

    零.参考资料 有关FPN的介绍见『计算机视觉』FPN特征金字塔网络. 网络构架部分代码见Mask_RCNN/mrcnn/model.py中class MaskRCNN的build方法的"in ...

  4. [转]HttpWatch工具简介及使用技巧

    http://www.cnblogs.com/mayingbao/archive/2007/11/30/978530.html 一 概述: HttpWatch强大的网页数据分析工具.集成在Intern ...

  5. HttpWatch工具简介及使用技巧(转)

    HttpWatch是一个可用于录制HTTP请求信息的工具,由Simtec Limited公司开发,其官网为:Http://www.httpwatch.com,HttpWatch只支持IE和Firefo ...

  6. [JavaWeb基础] 017.Struts2 和 ajax交互简介

    在网页开发中,我们为了只对网页的某块内容进行实时更新,而不对其他不需要更新的内容进行刷新,从而提高响应速度和节省流量,我们采用了页面的异步刷新技术Ajax,那么我们的Struts2框架在这一方面是如何 ...

  7. 【第5篇】AI语音简介

    1.3  AI语音简介 AI语音既人工智能语音技术,以语音识别技术为开端,实现人机语言的通信,包括语音识别技术(ASR).自然语言处理技术(NLP)和语音合成技术(TTS).通俗点说就是通过语音这个媒 ...

  8. 教孩子学编程 Python

    教孩子学编程   Python 目录 第1 章 Python 基础:认识环境 111 认识Python 312 用Python 编写程序 513 运行Python 程序 514 本章小结 615 编程 ...

  9. 教孩子学编程 python语言版PDF高清完整版免费下载|百度云盘|Python入门

    百度云盘:教孩子学编程 python语言版PDF高清完整版免费下载 提取码:mnma 内容简介 本书属于no starch的经典系列之一,英文版在美国受到读者欢迎.本书全彩印刷,寓教于乐,易于学习:读 ...

随机推荐

  1. linux内核设计模式

    原文来自:http://lwn.net/Articles/336224/ 选择感兴趣内容简单翻译了下: 在内核社区一直以来的兴趣是保证质量.我们需要保证和改善质量是显而易见的.但是如何做到却不是那么简 ...

  2. 【C++沉思录】句柄2

    1.[C++沉思录]句柄1 存在问题: 句柄为了绑定到Point的对象上,必须定义一个辅助类UPoint,如果要求句柄绑定到Point的子类上,那就存在问题了.2.有没有更简单的办法呢? 句柄使用Po ...

  3. python数据结构之二叉树遍历的实现

    本篇是实现二叉树的三种遍历,先序遍历,中序遍历,后序遍历 #!/usr/bin/python # -*- coding: utf-8 -*- class TreeNode(object): def _ ...

  4. 解决vbox下安装centos不能上网问题

    由于工作需要用到Centos做服务器,使用VBOX安装Centos7系统后发现不能上网,记录解决方法,以便下次使用.找到/etc/sysconfig/network-scripts/ifcfg-enp ...

  5. WPF 获取程序路径的一些方法,根据程序路径获取程序集信息

    一.WPF 获取程序路径的一些方法方式一 应用程序域 //获取基目录即当前工作目录 string str_1 = System.AppDomain.CurrentDomain.BaseDirector ...

  6. Navi.Soft30.产品.DataWindowNet.操作手册

    1概述 1.1功能简介 Sybase公司的PowerBuilder开发工具,在以前VS工具没有成事以前,是相当风光的.微软都要与其合作,学习它Db方面的技术,才成就了SQLServer数据库.PB开发 ...

  7. 同时大量连接导致的DDOS攻击,导致收发器宕机,用户大面积超时掉线

    前段时间一个客户改成电信网通自动路由后(当然和这个没有关系,但是客户一般没有分析能力,会多想),用户经常大面积掉线,用户才180多个,在线最多也才120多,十分苦恼,原先帮其维护的技术人员,只是远程诊 ...

  8. dll return a string

    char g_szText[1024]; __declspec(dllexport) const char * __stdcall FuncName(const unsigned char *p) { ...

  9. C#中控件数组的讨论

    VB用得习惯后,到C#中来觉得很奇怪,如此好的控件数组怎么不见了.“众所周知,控件数组最主要的两个优点:可以循环附值:可以响应同一个事件.从而大大简化了代码.引自http://wenku.baidu. ...

  10. HTML5新特性之跨文档消息传输

    1.同域限制 所谓“同域限制”是指,出于安全考虑,浏览器只允许脚本与同样协议.同样域名.同样端口的地址进行通信. 2.window.postMessage方法 浏览器限制不同窗口(包括iFrame窗口 ...