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. samba4.1.9安装

    ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --with-piddir=/run/samba \ ...

  2. SimpleTemplate模板引擎开发

    模板引擎相信大家是经常使用的,但是实现原理估计没多少人知道(你要是说不就是replace嘛,那我也无话说了...). 先来看看这个SimpleTemplate想实现的是什么功能吧: 是个C#端的模板引 ...

  3. CDN技术分享

    CDN技术分享目录 网络应用服务发展 CDN技术 1.CDN是什么?为什么我们需要它?(简介) 2.CDN能做什么?(作用) 3.CDN是如何工作?(原理) 4.CDN有那些具体应用?(应用) 我们项 ...

  4. Chapter 5. Graph Theory:: Fundamentals:: Intermediate

    10457 - Magic Car 题意一开始看起来有点费解,其实最后就是要起点到终点的路径上最大边与最小边之差越小越好.这样我们可以先将边排个序,然后枚举路径上的最小边,之后依次将比它大的边按升序的 ...

  5. python数据结构之图的实现

    python数据结构之图的实现,官方有一篇文章介绍,http://www.python.org/doc/essays/graphs.html 下面简要的介绍下: 比如有这么一张图: A -> B ...

  6. 文件系统管理 之 实例解说 fdisk 使用方法

    一.fdisk 的介绍: fdisk - Partition table manipulator for Linux ,译成中文的意思是磁盘分区表操作工具:本人译的不太好,也没有看中文文档:其实就是分 ...

  7. 如何优雅的在MFC中使用cvSetMouseCallback?

    MFC与opencv的cvSetMouseCallback用起来感觉很不兼容. 大部分时候,用cvSetMouseCallback也许只是为了获取一个矩形框,或者绘制一个点,或者其它什么简易的图形,通 ...

  8. nginx 相关问题

    Nginx配置文件nginx.conf 参考:http://www.2cto.com/os/201212/176520.html Nginx自动切分日志: nignx没有自动分开文件存储日志的机制. ...

  9. ci配置smarty手记

    需要用ci来写一个后台配置smarty,在网络上能够找到一些相关的文章.但是都是比较旧的内容,大部分是smary2.*的配置方法.按照这个配置后会出现一些错误.其实配置看smary官方会比较简单. 基 ...

  10. 使用过滤器解决SQL注入和跨站点脚本编制

    1 SQL注入.盲注 1.1 SQL注入.盲注概述 Web 应用程序通常在后端使用数据库,以与企业数据仓库交互.查询数据库事实上的标准语言是 SQL(各大数据库供应商都有自己的不同版本).Web 应用 ...