selenium-webdriver - 使用示例 block 时,Cucumber 步骤不与步骤定义绑定(bind)

标签 selenium-webdriver automated-tests cucumber cucumber-java

我正在使用 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() {
    }

如有任何帮助,我们将不胜感激。

步骤定义图像:

Step definition image

最佳答案

在参数两边加上双引号后,现在工作正常。谢谢

功能文件代码:

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/

相关文章:

python - 在 Selenium 中通过带有特定文本的标签名称选择元素

javascript - 在 Cucumber.js 中是否可以列出所有可用的步骤?

ruby-on-rails-3.1 - 您不能同时使用 --strict 和 --wip (RuntimeError)

javascript - 是否内置选择器选项以使用 nightwatchjs 做出复杂的决策?

java - 通过 TestNG 在不同浏览器上运行 selenium 测试

java - 如何使用 Selenium Webdriver 在浏览器中读取 XML 内容?

reactjs - Testcafe - 如何迭代不同元素类型的选择器?

java - 使用 Java 测试登录时 Selenium 中的 NoSuchElementException

c++ - 如何在不生成大量测试客户端应用程序的情况下切换元素和容器类型以进行基准测试?

java - 如何解决解析功能文件时出现错误的runtime.cucumberException