首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium IDE:在新的测试脚本中包含测试脚本

Selenium IDE:在新的测试脚本中包含测试脚本
EN

Stack Overflow用户
提问于 2013-08-28 23:22:01
回答 2查看 2.2K关注 0票数 3

我们谷歌寻找解决方案,但不能成功,我们如何将已经录制的脚本添加到新脚本中。

EN

回答 2

Stack Overflow用户

发布于 2013-08-30 20:09:26

Selenium-Core有一个扩展:"include",它可以将另一个测试的内容添加到当前测试中。这是它在OpenQA维基上的页面:http://wiki.openqa.org/display/SEL/include,但不幸的是目前它还无法访问。我过去经常使用它,但最终放弃了它,转而使用汇总规则。

但是,如果您正在寻找在多个测试用例中重用脚本的方法,我强烈建议您使用Rollup规则。这是非常强大的,许多用户低估了Selenium IDE的特性。

使用Rollup规则的详细信息写在Selenium IDE的帮助页面上: menu help - UI-Element Documentation,然后通过关键字"Rollup“进行搜索。

票数 3
EN

Stack Overflow用户

发布于 2014-12-22 00:42:36

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

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

汇总脚本示例:

代码语言:javascript
复制
/**
 * 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;
    }
});

希望这能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18492031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档