ShardTestFiles - 每个实例的自定义参数不起作用

时间:2017-07-17 10:46:23

标签: protractor

我正在使用Protractor进行并行测试。问题是我有3个用户,我希望Protractor为每个实例自动选择一个免费用户。

let usersInActions = {};

const users = [
    { username: 'aaa', password: 'aaa'},
    { username: 'bbb', password: 'bbb'},
    { username: 'ccc', password: 'ccc'}
];

let config = {
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: ['incognito', 'disable-extensions']
        },
        maxInstances: 3,
        shardTestFiles: true
    },
    beforeLaunch: async () => {
        const capabilities = await browser.getCapabilities();
        const sesssionId = capabilities.get('webdriver.remote.sessionid');

        if (!browser.params.usersInActions) {
            browser.params.usersInActions = {};
        }

        const freeUser = users.find(u => {
            return !browser.params.usersInActions[sesssionId];
        });

        usersInActions[sesssionId] = freeUser;

        browser.params.user = freeUser;
    },
    afterLaunch: async () => {
        const capabilities = await browser.getCapabilities();
        const sesssionId = capabilities.get('webdriver.remote.sessionid');

        browser.params.usersInActions[sesssionId]  = null;
    }
};
  • 问题是每次调用新实例时都会重置usersInActions 。我相信这是 Protractor Bug

0 个答案:

没有答案