[译]WebReplay-用于Web应用程序的自动化软件测试工具
By robot-v1.0
本文链接 https://www.kyfws.com/applications/webreplay-an-automated-software-testing-tool-for-w-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2271 个词 阅读量 0[译]WebReplay-用于Web应用程序的自动化软件测试工具
原文地址:https://www.codeproject.com/Articles/10689/WebReplay-an-automated-software-testing-tool-for-W
原文作者:Emmanuel Kartmann
译文由本站 robot-v1.0 翻译
前言
This article presents an automated software testing tool for Web applications (Internet/Intranet) based on Internet Explorer.
本文介绍了一种基于Internet Explorer的Web应用程序(Internet/Intranet)的自动化软件测试工具.
介绍(Introduction)
网络重播是(Web Replay is an)Web应用程序的自动化软件测试工具(automated software testing tool for Web applications).通过重播场景来测试应用程序,它有助于检测Web应用程序中的错误和回归.(. It helps in detecting bugs and regressions in Web applications by replaying scenarios to test the application.)
使用WebReplay,您可以(Using WebReplay, you can)**自动地(automatically)****导航(navigate)**到网页,(to a Web page,)**填写(fill in)**表格栏位(form fields,)**点击(click)**单击提交(确定)按钮,然后继续到另一个网页.(on the submit (OK) button, and then continue to another Web page.)
要使用网络重播,(To use Web Replay,)建立一个XML方案文件(build an XML Scenario File)(请参见下文),在编辑框中输入文件名,然后单击"重播"按钮.((see below), type the name of the file in the edit box and click on the Replay button.)
背景(可选)(Background (optional))
网络重播基于Microsoft的(Web Replay is based on Microsoft’s) 网页浏览器(WebBrowser) 控件(Microsoft®ActiveX®控件).它将控件嵌入到一个非常简单的基于对话框的应用程序中,该应用程序加载XML方案文件并以编程方式驱动WebBrowser控件(通过其COM接口)(control (Microsoft® ActiveX® control). It embeds the control into a very simple dialog-based application which loads an XML scenario file and programmatically drives the WebBrowser control (via its COM Interface) iWebBrowser2(IWebBrowser2) )执行方案.() to execute the scenario.)
使用代码(Using the code)
Web重播提供以下功能:(Web Replay provides the following features:)
-
从XML文件重播场景.(Replay scenarios from an XML file.)
-
支持Microsoft Internet Explorer支持的所有功能(包括Windows集成身份验证).(Supports every feature supported by Microsoft Internet Explorer (includes Windows Integrated Authentication).)
-
支持HTML表单,HTML输入元素,HTML超链接(锚).(Supports HTML forms, HTML input elements, HTML hyperlinks (anchors).)
-
支持对HTML元素的两项操作:(Supports two actions on HTML elements:)
set_value
和(and)click
:(:)set_value
模拟HTML元素值的变化((simulates a change in the HTML element’s value ()input
,(,)select
等).(, etc…).)click
模拟在HTML元素(任何元素)上的鼠标单击.(simulates a mouse click on the HTML element (any element).)
-
支持未命名的HTML元素:可以找到元素及其关联的值和/或(Supports unnamed HTML elements: Elements can be found with their associated value and/or)
innerText
和/或(and/or)Href
.(.) -
存储并重新加载最后一个方案文件名(它使用的是旧的(Stores and reloads the last scenario file name (it uses a good old)*WebReplay.ini(WebReplay.ini)*文件).(file).)
-
支持动态生成的网站(客户端):如果您的网站在浏览器中生成HTML(使用JavaScript的"(Supports dynamically-generated Web Sites (client-side): If your web site generates HTML within the browser (using JavaScript’s commands like “)document.write(document.write)"),Web Replay仍然可以播放给定场景-它使用超时机制来查找动态生成的控件.("), Web Replay can still play back a given scenario - it uses a timeout mechanism to find the dynamically-generated controls.)
示例XML场景(Sample XML Scenario)
XML方案文件如下所示:(An XML scenario file looks like this:)
<?xml version="1.0" encoding="Windows-1252"?>
<web_replay>
<scenario>
<!--<span class="code-comment"> Search something in codeproject --></span>
<!--<span class="code-comment"> Scenarios are divided into steps (one step per page download) --></span>
<step>
<!--<span class="code-comment"> Every step can contain one or more actions --></span>
<!--<span class="code-comment"> Action can be of type "navigate" =
Web Replay will navigate to the given URL --></span>
<action type="navigate" url="http://www.codeproject.com" />
</step>
<step>
<!--<span class="code-comment"> Action can be of type "control" =
Web Replay will interact with an HTML element --></span>
<action type="control"
name="target" event="set_value" value="WebReplay" />
<!--<span class="code-comment"> This field is unnamed; but it has a specific value attribute --></span>
<action type="control" name="" value="Go" event="click" />
</step>
</scenario>
</web_replay>
要构建方案文件,您需要基本了解Web应用程序中HTML元素的名称(或ID).另外,您可以使用一个空名称并使用HTML元素的值(用于未命名的项目).(To build a scenario file, you need to basically know the names (or ids) of HTML elements within your Web Application. Alternatively, you can use an empty name and use the HTML element’s value (for unnamed items).)
兴趣点(Points of Interest)
您如何测试代码?好吧,只需编写一个测试程序! Web Replay通过提供一种简单的Web应用程序测试方法来帮助您实现这一目标.但这仍然是一个崭新的计划.待办事项清单很长…(How do you test code? Well, just write a test program! Web Replay helps you with this by providing a simple way of testing you Web apps. But it’s still a brand new program; the TODO list is long…)
网络重播TODO列表(Web Replay TODO List)
- 多次播放场景(甚至无限循环来对Web应用程序进行压力测试).(Play scenarios multiple times (even infinite loops to stress-test your Web application).)
- 在方案文件中使用变量/表达式(重播(Use of variables/expression in scenario files (to replay scenarios that are)**总是(always)**不同).(different).)
- 批量播放场景文件.(Batch playback of scenario files.)
- 增强的错误检测(例如,如果在HTML页面中未找到给定的HTML模式,则场景应失败).(Enhanced error detection (e.g. a scenario should fail if a given HTML pattern is not found in the HTML page).)
- 自动记录方案文件(为IWebBrowser2实现一个事件接收器,并记录HTML元素的名称/标识和相关事件).(Automated recording of scenario files (implement an event sink for IWebBrowser2 and record HTML elements names/id and associated event).)
历史(History)
V1.0-$日期:2005-06-16 11:50:08 +0200(2005年6月16日,星期四)$(V1.0 - $Date: 2005-06-16 11:50:08 +0200 (Thu, 16 Jun 2005) $)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ HTML VC7.0 WinXP Windows Win2K IE5.5 Visual-Studio IE6.0 Dev 新闻 翻译