我是黄瓜量角器的新手。我必须自动化一个流程,其中在输入名字,姓氏和邮政编码时,将创建一个新用户。我正在尝试在场景概述的示例中添加要在功能文件中输入的数据,如下所示:
Feature: Demo
Scenario Outline: Create a customer
Given I open the application and click on create customer button
When I enter <firstName>, <lastName>, <postCode>
Then customer should be created
Examples:
| firstName | lastName | postCode |
| Saloni | Singhal | 12345 |
| Harry | Potter | 67890 |
对于when子句,我在步骤def中添加了以下代码:
When('I enter {string}, {string}, {int}', async function (string,string,int) {
browser.sleep(10000);
await BankManagerButton.click();
await firstName.sendKeys(string);
await lastName.sendKeys(string);
await postCode.sendKeys(int);
return await addCustButton.click();
});
但是在运行此代码时,它给我带来未定义的错误,并提出以下建议:
Undefined. Implement with the following snippet:
When('I enter Saloni, Singhal, {int}', function (int) {
// When('I enter Saloni, Singhal, {float}', function (float) {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
对于所有方案都类似。那么,我是否必须分别为每个数据编写代码,还是可以仅使用一个函数来处理它?如果是,我该怎么做?
https://cucumber.io/docs/cucumber/cucumber-expressions/
{string}
匹配单引号或双引号的字符串,例如“香蕉分割”或“香蕉分割”(但不包括香蕉分割)。仅提取引号之间的文本。引号本身将被丢弃。空的引号对是有效的,将被匹配并作为空字符串传递给步骤代码。
所以:
When I enter "<firstName>", "<lastName>", "<postCode>"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句