角括号参数在Cucumber Feature文件执行完成后不会被替换为Cucumber js。

huangapple go评论95阅读模式
英文:

Angular bracket arguments don't get replaced in Cucumber Feature file after completion of execution in cucumber js

问题

我正在使用Cucumber JS与Node.js和WebdriverIO。

我在步骤定义文件中编写了钩子,如下所示:

Given(/^I login with username (.*) and password (.*)$/, function(username,password) {
       pageModule.open();
       pageModule.Login("abc","abc");
       return Promise.resolve();
});

我已经使用以下方式的特性文件:

Scenario: Create New
          Given I login with username "<username>" and password "<password>"

执行后,生成的报告显示特性文件中的<username><password>未替换为实际值。

英文:

I'm using cucumber js with node js and webdriverio.

I have written hooks in step definition file like..

Given(/^I login with username (.*) and password (.*)$/, function(username,password) {
       pageModule.open();
       pageModule.Login(&quot;abc&quot;,&quot;abc&quot;);
       return Promise.resolve();
});

I have used Feature file as follows

Scenario: Create New
          Given I login with username &quot;&lt;username&gt;&quot; and password &quot;&lt;password&gt;&quot;

After execution , reports are generated like.. <username> and <password> in feature file is not replaced with actual values

角括号参数在Cucumber Feature文件执行完成后不会被替换为Cucumber js。

答案1

得分: 1

如果您需要使用多个用户名和密码:

  1. 我们需要将其声明为“Scenario Outline”而不仅仅是“Scenario”。

  2. 我们需要按以下格式创建一个“Scenario Outline”:

    Scenario Outline: 创建新用户
    Given 我使用用户名 和密码 登录
    Examples:
    |username|password|
    |firstUserName|firstPassword|
    |secondUserName|secondPassword|

通过这种方式,我们的场景将使用示例表中显示的多个示例重复执行,以证明我们正在验证的内容。

英文:

If you need to take multiple user names and passwords:

  1. We need to declare it as Scenario Outline instead only Scenario

  2. We need to create a Scenario Outline in below format:

    Scenario Outline: Create New
    Given I login with username <username> and password <password>
    Examples:
    |username|password|
    |firstUserName|firstPassword|
    |secondUserName|secondPassword|

By this way, our scenario will be repeated with multiple examples what we are proving in Examples table shown like above.

huangapple
  • 本文由 发表于 2020年1月3日 17:18:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/59575872.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定