So I'm trying to test my feature files on steps class. I'm having an issue asserting multiple common scenarios linked to the same step definition.
- Forex;
- Feature: Cucumber Automation
Scenario: Validate menu items
- Given user is on "https://www.example.com/"
- When user clicks "XYZ" menu item
- Then user should navigate to "https://www.example.com/xxx/"
- And user should get "XXXX" text
- And user should get "Some random text" text
So these 2 "And" steps are validating in single step definition. I'm trying to assert the "And" with two different locators with from the POM classes.
@And("user should see {string} text")
public void userShouldSeeText(String key) {
Assert.assertEquals(key, helpMeSearchPage.mainHeader.getText());
Assert.assertEquals(key, helpMeSearchPage.subHeader.getText());
Assert.assertEquals(key, helpMeSearchQaPage.header.getText());
Assert.assertEquals(key, helpMeSearchQaPage.subHeading.getText());
}
But it doesn't work, my each Assert line runs twice already and I couldn't find the solution. I'm trying to learn JUnit Cucumber but having issue on this step.