我有一个黄瓜方案概述,我想在其中传递6个空格字符串的示例表(“”)作为值。在“示例”表中,仅将值保留为空白,并传递一个空字符串。我尝试使用双引号和单引号,它是相同的。它传递8个字符串(包括2个引号),而不是6。
这是方案大纲的外观:
方案概述:更改密码-负数无效的确认密码
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 |
这就是特征定义的样子:
当(/ ^我插入无效的ConfirmPassword(。*)$ /,异步(confirmNewPass:string)=> {等待changePasswordPage.changePasswordComponent.insertConfirmNewPassword(confirmNewPass);});
您需要创建这样的特征文件
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" |
然后在步骤定义中,您将必须使用黄瓜表达。
示例代码写在下面
@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);
}