网页自动测试工具

更新时间:2023-08-15 21:50:01 阅读量: 教学研究 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法............

网页自动测试工具

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.

Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.

Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.

iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法.

1.下载iMacros for Firefox 插件在Firefox浏览器中安装,安装完重新打开浏览器,左边回自动打开Macros for Firefox工具,如图1所示:

2.打开测试页面form.html,如图2

所示:图1

图2

注:form.html页面代码见附件一

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法............

3.安装了插件后找到iMacros下的Datasources文件夹,新建一个名为form.csv的文件,然后将数据全部写入,在此以三条记录为例,如图3所示:

图3

注:文件头字段必须与表单各标签的name属性值相同.

4.编写form.imm文件,将文件放入iMacros下的Macros文件夹,代码如下:

VERSION BUILD=3700331

'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database

TAB T=1

TAB CLOSEALLOTHERS

' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file

'CSV = Comma Separated Values in each line of the file

CMDLINE !DATASOURCE form.csv

'Number of columns in the CSV file. This must be accurate!

SET !DATASOURCE_COLUMNS 8

SET !FILESTOPWATCH blog.csv

SET !ERRORIGNORE NO

'Start at line 2 to skip the header in the file

SET !LOOP 2

'Increase the current position in the file with each loop

SET !DATASOURCE_LINE {{!LOOP}}

' Fill web form

URL GOTO=file:///E:/JQuery/mydojo/JQuery/JQuery/yanzheng.html

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:cusername CONTENT={{!COL1}}

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:cemail CONTENT={{!COL2}}

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:curl CONTENT={{!COL3}}

TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=ID:ccomment CONTENT={{!COL4}}

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:cvalcode CONTENT={{!COL5}}

5.点击工具的编辑---刷新宏列表,form.imm就会显示在列表中,选中form.imm,设置最大值为4,点击播放(循环),工具将自动运行测试每一组数据。

存在问题:数据可以被循环的自动测试,但是无法将不符合表单内容输入规则的数据信息抓取出来,有待解决.

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法............

附件一:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>form</title>

<script src="../js/jquery-1.3.1.js" type="text/javascript"></script>

<script src="../js/jquery.validate.js" type="text/javascript"></script>

<style type="text/css">

*{ font-family: Verdana; font-size: 96%; }

label { width: 10em; float: left; }

label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }

p { clear: both; }

.submit { margin-left: 12em; }

em { font-weight: bold; padding-right: 1em; vertical-align: top; }

em.error {

background:url("../images/unchecked.gif") no-repeat 0px 0px;

padding-left: 16px;

}

em.success {

background:url("../images/checked.gif") no-repeat 0px 0px;

padding-left: 16px;

}

</style>

<script type="text/javascript">

$(document).ready(function(){

$("#commentForm").validate({ rules: { username: { }, email: { }, url:"url", comment: "required", valcode: { formula: "7+9" required: true, email: true required: true, minlength: 2

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法............

}, messages: { }, } username: { }, email: { }, url: '请检查网址的格式', comment: '请输入您的评论' required: '请输入电子邮件', email: '请检查电子邮件的格式' required: '请输入姓名', minlength: '请至少输入两个字符' errorElement: "em", //用来创建错误提示信息标签 success: function(label) { } //验证成功后的执行的回调函数 //label指向上面那个错误提示信息标签em label.text(" ") //清空错误提示消息 .addClass("success"); //加上自定义的success类 });

});

</script>

</head>

<body>

<form class="cmxform" id="commentForm" method="get" action=""> <fieldset>

<legend>一个简单的验证带验证提示的评论例子</legend>

<p>

<label for="cusername">姓名</label>

<em>*</em><input id="cusername" name="username" size="25" /> </p>

<p>

<label for="cemail">电子邮件</label>

<em>*</em><input id="cemail" name="email" size="25" />

</p>

Watir:使用 Ruby 实现的,脚本也是Ruby 的脚本.Sahi:无法对本地的页面进行测试,可对在线页面操作进行刻制和回放.Canoo WebTest:不能编程插入数据,这样每次只能有一条值插入,不是很好.iMacros for Firefox :iMacros for Firefox是Firefox浏览器的一个插件,能够批处理测试表单数据,下面详细介绍一下该软件的测试方法............

<p>

<label for="curl">网址</label>

<em> </em><input id="curl" name="url" size="25" value="" /> </p>

<p>

<label for="ccomment">你的评论</label>

<em>*</em><textarea id="ccomment" name="comment" cols="22"></textarea> </p>

<p>

<label for="cvalcode">验证码</label>

<input id="cvalcode" name="valcode" size="25" value="" />=7+9 </p>

<p>

<input class="submit" type="submit" value="提交"/>

</p>

</fieldset>

</form>

</body>

</html>

本文来源:https://www.bwwdw.com/article/keoj.html

Top