Selenium IDE: Include test script to new test script

只谈情不闲聊 提交于 2019-12-19 09:55:50

问题


We google to find the solution but could not succeed, how do we add already recorded script into new script.


回答1:


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".




回答2:


I ended up using Rollups as suggested by Yevgen. It took me some time to find the proper way to implement this. The basic idea is you end up writing a JavaScript file that is added to Selenium IDE under options/options in the Selenium Core Extensions setting. The JavaScript file, which you need to write to build your "reusable command stack", will allow you to use the built-in rollup command with the target being set to the label you assign to a group of commands.

I wrote an article about Selenium IDE Includes AKA Rollups that may be a useful resource.

An example rollup script:

/**
 * 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;
    }
});

Hope that helps.



来源:https://stackoverflow.com/questions/18492031/selenium-ide-include-test-script-to-new-test-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!