2

I am using cucumber with java. When i am trying to pass value from Example block steps are not binding with the step definitions. Throwing steps undefined step reference error on feature file.

Feature File code:

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   |

Step Definition code that i tried:

@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() {
    }

Any help would be appreciated.

Step definition image:

Step definition image

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Adil Raza
  • 65
  • 6

2 Answers2

2

After putting double quotes around the parameter, Now workin fine.Thanks

Feature File code:

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   |
Adil Raza
  • 65
  • 6
  • But I strongly believe my proposed [solution](https://stackoverflow.com/questions/70811655/cucumber-step-not-binding-with-step-definitions-when-using-example-block/70816252#70816252) should have addressed the error for which you have raised the question. – undetected Selenium Jan 23 '22 at 16:52
1

Your program is Throwing steps undefined step reference error on feature file as you have duplicate column headers with text as username.

|  text      | output | username | username |

You may like to change it as:

|  text      | output | username | password |
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    when i keep my parameter in "<>" it started working. – Adil Raza Jan 23 '22 at 15:54
  • That's because you didn't put quotes around **strings** in your table @adil raza. This makes sense if you got source data like numbers in there as well. – MiB Mar 25 '22 at 16:45