黄瓜方案概述:传递空格字符串""作为“示例"表中的值 [英] Cucumber Scenario Outline: Passing space strings " " as value in Examples table

查看:85
本文介绍了黄瓜方案概述:传递空格字符串""作为“示例"表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个黄瓜方案纲要,其中的示例"表我想传递6个空格字符串(")作为值.在示例"表中,仅将值保留为空白,并传递一个空字符串.我尝试使用双引号和单引号,它是相同的.它传递8个字符串(包括2个引号),而不是6个.

I have a Cucumber Scenario Outline in which Examples table I would like to pass 6 space strings (" ") as value. In the Example table just leaving the value blank, passes an empty string. I tried with double and single quotes and it is the same. It passes 8 strings (including 2 quotes), instead of 6.

这是方案大纲的外观:

Scenario Outline: Change password - Negative Invalid Confirm Password

    Given I log in as a user on the change password page
    When I insert the current password
    And I insert password
    And I insert invalid confirm password <value>
    And I move focus to another element on the change password page
    Then <message> appears under the confirm password field

    Examples:                                                                                       
             |value           |message                           |
             |Aa1!            |Passwords Invalid or Do Not Match |
             |"      "        |Passwords Invalid or Do Not Match |

这是特征定义的样子:

When(/^I insert invalid confirmPassword (.*)$/, async (confirmNewPass:string) => {
  await changePasswordPage.changePasswordComponent.insertConfirmNewPassword(confirmNewPass);
});

推荐答案

您需要创建这样的特征文件

You need to create feature file like this

Feature: Title of your feature
  I want to use this template for my feature file


  Scenario Outline: Title of your scenario outline
    Given I want to write a step 
    When I check for the <value> in step
    Then I verify the <message> in step

    Examples: 
     |value              |message                           |
     | "Aa1!"            | "Passwords Invalid or Do Not Match" |
     | "      "          | "Passwords Invalid or Do Not Match" |

,然后在步骤定义中,您将不得不使用黄瓜表达.

and then in the step definition you will have to use cucumber expression.

示例代码写在下面

@Given("I want to write a step")
public void i_want_to_write_a_step() {
    // Write code here that turns the phrase above into concrete actions
    System.out.println("In a given method!");
}
@When("I check for the {string} in step")
public void i_check_for_the_Aa1_in_step(String value) {
    // Write code here that turns the phrase above into concrete actions
     System.out.println("Value: " + value);
}


@Then("I verify the {string} in step")
public void i_verify_the_Passwords_Invalid_or_Do_Not_Match_in_step(String message) {
    System.out.println("Message: " + message);
}

这篇关于黄瓜方案概述:传递空格字符串"&quot;作为“示例"表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆