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. BZOJ 4300: 绝世好题 动态规划

    4300: 绝世好题 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4300 Description 给定一个长度为n的数列ai,求ai的 ...

  2. hive中同列多行数据组合的方法以及array to string要点(行转列)

    1. 同列多行数据组合成一个字段cell的方法, top N 问题的hive方案 如下: hive 列转行 to json与to array list set等复杂结构,hive topN的提取的窗口 ...

  3. .NET Actor Model Implementations Differ in Approach

    Last week Vaughn Vernon, author of Implementing Domain-Driven Design, published Dotsero, a .NET Acto ...

  4. SDN论坛看到BW的问题及相关解答

    SDN论坛看到BW的问题及相关解答 链接: http://blog.sina.com.cn/s/blog_5c58e3c70100r1ou.html 现在有一个 QUERY 运行十分慢 , 所以我想在 ...

  5. android google 统计导致的文件冲突

    android studio 加入google 统计 1. buildscript { repositories { jcenter() } dependencies { classpath 'com ...

  6. iOS项目立项

    哎,计划总是赶不上变化,仿佛又回到了十年前高三的时候,每月.每周.每天都有计划,但是每周.每天都有计划外的因素导致了计划时时变,唯一不变的就只有变化了. 想了许久,中期计划内还是转回iOS吧,说转回其 ...

  7. 构建基于WinRT的WP8.1 App 01:页面导航及页面缓存模式

    本篇博文主要阐述基于Windows Runtime的Windows Phone 应用页面间导航相关知识,主要分为以下几个方面: Window.Frame和Page概览 页面间实现跳转 处理物理后退键 ...

  8. Android-NDK编译:cocos2d-x(三) eclipse 导入工程

    NDK 编译后,用eclipse导入cocos2d-x工程 菜单[File]-->[New]-->[Project] ,弹出New Project 对话框 窗口下方 选 [Android] ...

  9. AndroidTouchGalleryLibrary 优化

    AndroidTouchGalleryLibrary 是一个非常好用的库, 但是使用的时候,需要小心处理,容易引发OutOfMemoryError,同时使用UrlTouchImageView的时候, ...

  10. 爬网页?--Chrome帮你计算XPath

    最近用HtmlUnit/HtmlCleaner爬网页,这两个工具都使用XPath来定位html元素.发现chrome竟然有算出XPath的功能! 打开一个网页,F12,在弹出的小窗口中选中一个标签,右 ...