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. 转:TinyXM--优秀的C++ XML解析器

    读取和设置xml配置文件是最常用的操作,试用了几个C++的XML解析器,个人感觉TinyXML是使用起来最舒服的,因为它的API接口和Java的十分类似,面向对象性很好. TinyXML是一个开源的解 ...

  2. Web前端知识技能大汇总

    项目起源 还记得@jayli 的这幅前端知识结构图么. 图片的形式具有诸多的不便.缺失源图的我们,无法为此图贡献些什么,随着时间的迁移,或许有些技术点会发生改变,所以有了这个GitHub项目.我们可以 ...

  3. A CIRCULAR PROGRESSBAR STYLE USING AN ATTACHED VIEWMODEL

    This blog post describes how to re-template the Silverlight ProgressBar control to render a circular ...

  4. CentOS 6.5 EasyPR环境搭建

    EasyPR是一款开源的中文车牌识别系统,项目地址. 在搭建的过程中,主要的问题是注意版本的兼容性,这里面的版本包括:opencv版本,g++版本以及cmake版本. 我使用的EasyPr版本信息如下 ...

  5. Eclipse shortcuts

    Editor Shortcut Description Alt + / Content assist. A great help for our coding. Ctrl + Shift + F Fo ...

  6. 修改eclipse启动时eclipse使用的jre

    eclipse在启动的时候,和环境变量中的jdk不兼容,可以单独制定eclipse运行的jre. 方法: 在eclipse的配置文件里增加-vm参数即可. 打开eclipse目录下的eclipse.i ...

  7. ubuntu 12 JDK 编译

    下载openjdk源码 http://jdk7.java.net/source.html 安装Ubuntu上面的依赖包: .参考原书 环境变量配置: .去www.hzbook.com上面将深入理解ja ...

  8. 301 redirect Domain Name using global.asax

    void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Request.Url.ToSt ...

  9. 所有文章都迁移到我自己的博客了:http://blog.neazor.com

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  10. iOS:基于AVPlayer实现的视频播放器

    最近在学习AVFoundation框架的相关知识,写了一个基于AVPlayer的视频播放器,相关功能如下图: 代码github:https://github.com/wzpziyi1/VideoPla ...