本站首页    管理页面    写新日志    退出


«October 2025»
1234
567891011
12131415161718
19202122232425
262728293031


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7625696
建立时间:2006年5月29日




[集成测试]Selenium测试 使用笔记
软件技术

lhwork 发表于 2006/10/30 11:45:04

看了江南白衣 的 Selenium--透明反复推介的集成测试工具(Pragmatic系列)确实不错。值得推荐使用。但是有的时候确实也挺麻烦。比如说,我一个页面可能有上百个文本框。等很多动作。那在Junit 里可能要 写 一段很长的代码了。像    test.open("/");    test.click("");     test.type("");。。。。。。。。。。。。。。。。。 我想在稍微大点的项目中 这样写测试代码 可能也是个噩梦。。解决办法1.如果没有安装firefox 下载fireFox   2.Selenium IDE下载  Selenium IDE https://addons.mozilla.org/firefox/2079/Firefox > Tools > Selenium IDE Selenium IDE > Options > Options... 选择 Format 选项. 点击添加按钮. (Name of the fommat )给新添的起个名字 testSelenium粘贴下面JS代码到文本恇 点击确定 点击工具 菜单 Selenium IDE > Options > Format > testSelenium可以录脚本了testSelenium.jsvar  SEPARATORS = {  pipe: "|",  comma: ",",  tab: "\t"};function formatCommands(commands) {  var result = '';  var sep = SEPARATORS[options.separator];  var prefix = options.wrap == 'true' ? sep : "";  var postfix = prefix;  for (var i = 0; i < commands.length; i++) {    var command = commands[i];    if (command.type == 'command') {      result += prefix + command.command + sep + command.target + sep + command.value + postfix + "\n";    }  }  return result;}function parse(testCase, source) {  var doc = source;  var commands = [];  var sep = SEPARATORS[options.separator];  var base = options.wrap == 'true' ? 1 : 0;  while (doc.length > 0) {    var line = /(.*)(\r\n|[\r\n])?/.exec(doc);    var array = line[1].split(sep);    if (array.length >= (base+3)) {      var command = new Command();      command.command = array[base+0];      command.target = array[base+1];      command.value = array[base+2];      commands.push(command);    }    doc = doc.substr(line[0].length);  }  testCase.setCommands(commands);}function format(testCase, name) {  return formatCommands(testCase.commands);}options = {    separator: 'pipe',    wrap: 'true'};configForm =     '<description>Separator</description>' +     '<menulist id="options_separator">' +    '<menupopup>' +    '<menuitem label="Pipe" value="pipe"/>' +    '<menuitem label="Comma" value="comma"/>' +    '<menuitem label="Tab" value="tab"/>' +    '</menupopup>' +    '</menulist>' +    '<checkbox id="options_wrap" label="Wrap command with separator"/>';最后 录制的 脚本 如下Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->base url http://www.cnblogs.com/|open|/|||clickAndWait|link=注册|||type|ctl00_cphMain_tbApplicant|junmy||type|ctl00_cphMain_tbEmail|wunjunlove(At)gmial.com||type|ctl00_cphMain_tbCompany|msSonft||type|ctl00_cphMain_tbCity|shenzhen||type|ctl00_cphMain_tbApplyText|teeee详细申请理由(比如:技术专长,感兴趣的技术,在Blog中写哪方面的内容||click|ctl00_cphMain_btnSend||把此录制的脚本 保存为一个文件。再写一个类专门来处理分析 这个脚本就不用 在Junit测试 写 那么长的 像    test.open("/");    test.click("");    user.type("");等特长的代码了 。


阅读全文(4712) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.047 second(s), page refreshed 144793276 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号