如何让黄瓜中的数据表成为可选?

问题描述 投票:0回答:1

我们可以将数据表设为可选参数吗,下面我有两种情况

When(/^I (enter|select)?(( and select)? the following fields )?( "(.*?)" in the )("(.*?)" field )?in the files management page$/, function (actionType, condition, value, fieldName, table) {
    filesManagementUtil.enterOrSelectValueInFilesManagement(actionType, value, fieldName, table);
});

步骤应该是

When I enter "Field Value" in the "Business Name" field in the files management page

When I enter the following fields in the files management page
            | FieldName     | FieldValue  | Action |
            | Business Name | Field Value | Enter  |

步骤定义应该适用于下面的两种情况

When I enter "Field Value" in the "Business Name" field in the files management page

When I enter the following fields in the files management page
            | FieldName     | FieldValue  | Action |
            | Business Name | Field Value | Enter  |
cucumber cucumberjs
1个回答
0
投票

你不能。 您需要使用两个步骤。 见下图:

/**
 * When I enter "Field Value" in the "Business Name" field in the files management page
 */
this.When(/^I enter "(.*)" in the "(.*)" field in the files management page$/, { timeout: IO_WAIT }, function step(value, field) {
    enterFieldValue(value, field);
});



/**
 * When I enter the following fields in the files management page
 */
this.When(/^I enter the following fields in the files management page:$/, { timeout: IO_WAIT }, function step(table) {

    if (table.rawTable[0].length < 1) {
        assert.ok(false, 'Table is misconfigured in scenario.');
    }

    table.rawTable[0].forEach((value,field) => {
        enterFieldValue(value, field);
    }
        
});
© www.soinside.com 2019 - 2024. All rights reserved.