我们谷歌找到解决方案但无法成功,我们如何将已录制的脚本添加到新脚本中。
2 回答
There is an extension for Selenium-Core: "include", which can add the content of another test to the current test. Here is it's page on OpenQA wiki: http://wiki.openqa.org/display/SEL/include, but unfortunately at the moment it is not accessible. I used to use it in the past but eventually gave it up in a favor of ROLLUP RULES.
But if you are looking for a way to reuse a script in several test cases I would strongly recommend you use Rollup Rules. That is very powerful and underestimated by a lot of users feature of Selenium IDE.
Details of using Rollup Rules is written on a help page in Selenium IDE: menu Help - UI-Element Documentation, then search by keyword "Rollup".
我最终按照 Yevgen 的建议使用了汇总。我花了一些时间才找到实现这一点的正确方法。基本思想是您最终编写了一个 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;
}
});
希望有帮助。