我正在使用 Cucumber 和 java。当我尝试从示例 block 传递值时,步骤不与步骤定义绑定(bind)。在功能文件上抛出步骤未定义的步骤引用错误。
功能文件代码:
Scenario Outline: Verify "Create your account" button on the Profile screen for Guest user
Given I launched the app
When I skip the On-boarding flow
And I tap on continue with free lessons button
And I tap on Profile tab
Then the output should be <output>
Then I should be able to see <text> on profile screen
And I enter Username as <username> and Password as <username>
And I tap create your account button on profile screen
Then I should redirected to Create your account screen
Examples:
| text | output | username | pwd |
|Register now| 5000 | sam | willis |
我尝试过的步骤定义代码:
@Then("I should be able to see {string} on profile screen")
public void i_should_be_able_to_see_register_now_to_save_your_xp_and_access_your_full_profile_on_profile_screen(String text) {
profile = new Profile();
Assert.assertTrue(profile.verifyLevelTagForGuestUser(text));
}
@Then("I should be able to see <text> on profile screen")
public void iShouldBeAbleToSeeTextOnProfileScreen(String output) {
profile = new Profile();
Assert.assertTrue(profile.verifyLevelTagForGuestUser(output));
}
@When("^I enter Username as \"([^\"]*)\" and Password as \"([^\"]*)\"$")
public void I_enter_Username_as_and_Password_as(String arg1, String arg2) {
}
@And("I enter Username as <username> and Password as <username>")
public void iEnterUsernameAsUsernameAndPasswordAsUsername() {
}
如有任何帮助,我们将不胜感激。
步骤定义图像:
最佳答案
在参数两边加上双引号后,现在工作正常。谢谢
功能文件代码:
Scenario Outline: Verify "Create your account" button on the Profile screen for Guest user
Given I launched the app
When I skip the On-boarding flow
And I tap on continue with free lessons button
And I tap on Profile tab
Then the output should be "<output>"
**Then I should be able to see "<text>" on profile screen**
And I enter Username as "<username>" and Password as "<username>"
And I tap create your account button on profile screen
Then I should redirected to Create your account screen
Examples:
| text | output | username | pwd |
|Register now| 5000 | sam | willis |
关于selenium-webdriver - 使用示例 block 时,Cucumber 步骤不与步骤定义绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70811655/