2013-08-28 42 views

回答

3

Selenium-Core有一个扩展:“include”,它可以将另一个测试的内容添加到当前测试中。 以下是OpenQA wiki上的页面:http://wiki.openqa.org/display/SEL/include,但不幸的是目前无法访问。 我曾经在过去使用它,但最终放弃了ROLLUP RULES。

但是,如果您正在寻找一种在多个测试用例中重用脚本的方法,我强烈建议您使用汇总规则。这是Selenium IDE的许多用户功能非常强大和低估的。

使用汇总规则的详细信息写在Selenium IDE的帮助页面上:菜单帮助 - UI元素文档,然后按关键字“汇总”进行搜索。

+0

谢谢,我会尽力的。 – Faiyaz

0

我最终使用了Yevgen建议的Rollups。我花了一些时间来找到实现这一点的正确方法。基本思想是编写一个JavaScript文件,并将其添加到Selenium IDE的Selenium Core Extensions设置下的options/options下。您需要编写的JavaScript文件才能构建“可重用的命令堆栈”,这将允许您使用内置汇总命令,并将目标设置为您分配给一组命令的标签。

我写了一篇关于Selenium IDE Includes AKA Rollups的文章,可能是一个有用的资源。

一个例子汇总脚本:

/** 
* For use in Selenium IDE. 
* 
* You will need to add this to Selenium under Options/Options in the Selenium Menu. 
* Put this under Selenium Core Extensions: 
* ~/selenium-ide-for-slp/sideflow.js , ~/selenium-ide-for-slp/slp_rollups.js 
* 
* 
*/ 
var manager = new RollupManager(); 


/** 
* check_for_syntax_errors 
* 
* This rollup tests for php syntax errors, warnings, and notices. 
*/ 
manager.addRollupRule({ 
    name: 'check_for_syntax_errors', 
    description: 'Check for PHP syntax errors, notices, warnings.', 
    args: [], 
    commandMatchers: [], 
    getExpandedCommands: function(args) { 
     var commands = []; 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Notice: Undefined*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '**Notice: Trying to get*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Notice: Use of*' 
     }); 

     commands.push({ 
      command: 'assertNotText', 
      target: '//body', 
      value: '*Fatal error:*' 
     }); 

     return commands; 
    } 
}); 

希望有所帮助。