WatiN和HttpWatch交互简介
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
- 添加httpwatch自动化类库到项目中
- 创建与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交互简介的更多相关文章
- HttpWatch工具简介及使用技巧(转载)
一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...
- HttpWatch工具简介及使用技巧
一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...
- 『计算机视觉』Mask-RCNN_推断网络其二:基于ReNet101的FPN共享网络暨TensorFlow和Keras交互简介
零.参考资料 有关FPN的介绍见『计算机视觉』FPN特征金字塔网络. 网络构架部分代码见Mask_RCNN/mrcnn/model.py中class MaskRCNN的build方法的"in ...
- [转]HttpWatch工具简介及使用技巧
http://www.cnblogs.com/mayingbao/archive/2007/11/30/978530.html 一 概述: HttpWatch强大的网页数据分析工具.集成在Intern ...
- HttpWatch工具简介及使用技巧(转)
HttpWatch是一个可用于录制HTTP请求信息的工具,由Simtec Limited公司开发,其官网为:Http://www.httpwatch.com,HttpWatch只支持IE和Firefo ...
- [JavaWeb基础] 017.Struts2 和 ajax交互简介
在网页开发中,我们为了只对网页的某块内容进行实时更新,而不对其他不需要更新的内容进行刷新,从而提高响应速度和节省流量,我们采用了页面的异步刷新技术Ajax,那么我们的Struts2框架在这一方面是如何 ...
- 【第5篇】AI语音简介
1.3 AI语音简介 AI语音既人工智能语音技术,以语音识别技术为开端,实现人机语言的通信,包括语音识别技术(ASR).自然语言处理技术(NLP)和语音合成技术(TTS).通俗点说就是通过语音这个媒 ...
- 教孩子学编程 Python
教孩子学编程 Python 目录 第1 章 Python 基础:认识环境 111 认识Python 312 用Python 编写程序 513 运行Python 程序 514 本章小结 615 编程 ...
- 教孩子学编程 python语言版PDF高清完整版免费下载|百度云盘|Python入门
百度云盘:教孩子学编程 python语言版PDF高清完整版免费下载 提取码:mnma 内容简介 本书属于no starch的经典系列之一,英文版在美国受到读者欢迎.本书全彩印刷,寓教于乐,易于学习:读 ...
随机推荐
- pgpgin|pgpgout|pswpin|pswpout意义与差异
引用来自: http://ssms.cs2c.com.cn/otrs/pc.pl?Action=PublicFAQZoom;ItemID=11741 文章主要意思是: 1. page in/out操作 ...
- EF5.0增删改查的写法及执行Sql的方法
public T AddEntity(T entity) { //EF4.0的写法 添加实体 //db.CreateObjectSet<T>().AddObject(entity); // ...
- android studio logcat 换行(日志换行)
起因 今天突然要调试网络数据,调试一大截那个xml数据. 解决思路 一开始去setting哪里看一下logcat 是否有line break,类似的字眼,可惜没有. 我猜如果没有在设置的话,估计就在“ ...
- 初探单点登录 SSO
单点登录 单点登录(Single sign-on,SSO)是一种访问控制,在多个软件应用中,用户只需登录其中一个应用,就可以成功访问其他应用:同样,用户只需注销其中一个应用,就可以成功注销其他应用. ...
- Swift基础--手势识别(双击、捏、旋转、拖动、划动、长按)
// // ViewController.swift // JieUITapGestureRecognizer // // Created by jiezhang on 14-10-4. // ...
- 老鼠跑猫叫主人惊醒c++观察者模式实现
这个题目算是比较经典的观察者模式了,老鼠作为一个Subject,主动发出跑的动作,紧跟着猫由于老鼠的跑而发出叫声,主人也被惊醒,在这里猫跟主人都是被动的,是观察者角色,代码实现如下: class CS ...
- window 内核详尽分析
http://bbs.pediy.com/showthread.php?t=185055
- WindowsCE project missing - 转
00x0 前言 之前在Windows 7系统中开发的WindowsCE项目,最近换成Windows 10系统,需要将项目进行修改,打开项目后提示如下错误: 无法读取项目文件“App.csproj”.. ...
- C primer plus 练习题 第三章
5. #include <stdio.h> int main() { float you_sec; printf("请输入你的年龄:"); scanf("%f ...
- NSURLSession与AFNetworking3.0
下面是用GET方式请求一个页面数据的示例: AFNetworking 2.x NSString *siteUrl = @"http://webinar.ofweek.com/readDemo ...