I am new at Cucumber. I am trying to write a feature file that tests
I have written this feature file. It doesn't seem correct.
Then
s.The feature file is like
Scenario: Admin user should be able to assign ReadOnly role to a searched user via Change User page
Given user logs into webapp with Admin role
And Navigates to Change User page
When user searches for user with id 123
And clicks select link corresponding to correct id
Then Change User page loads
And it has a new drop down with Read Only role
And when user selects MS distributor in drop down # note when with small w
And Presses Submit button then a new entry is saved in DB table # then with small t
Or maybe I can use the following:
Scenario: Admin user should be able to assign ReadOnly role to a searched user via Change User page
Given user logs into webapp with Admin role
And Navigates to Change User page
When user searches for user with id 123
And clicks select link corresponding to correct id to open Change User page
And it has a new drop down with Read Only role # need to check this new value in my selenium test case
And when user selects MS distributor value in drop down # note when with small w
And presses Save button
Then a new entry is saved in DB table
I'm looking forward to learning from your experience.
With what I understand so far, I'd write your scenario something like this:
Scenario: Admin user should be able to assign ReadOnly role to a searched user via Change User page
When I log in as an admin
And I navigate to the Change User page
And I search for the user with ID 123
And I click the link to user 123's Change User page
And I select the MS distributor value from the dropdown with the Read Only role
And I press the Save button
Then a new entry is saved in the database table
The main point is that there is no need to assert that the dropdown exists. Just use it. If the dropdown doesn't exist, the scenario will fail.
When
(and And
s following When
s) is for user actions. Then
(and And
s following Then
s) is for assertions. It's fine to have multiple When
/Then
sections in a single scenario; there is just no need for that here. I like a blank line before the second and later When
s to make it easier to see that there are multiple such sections.
Other points:
Every step should have a clear subject, meaning the subject of the sentence: "the user" or "I". I used "I" rather than "the user" for brevity. It would be fine to use "the user" throughout too.
I'd use When
rather than Given
for your first two steps because they're worded as though they are part of the series of actions that the user is taking. Alternatively, you could write two steps worded as though what they say were already the case and use them with Given
:
Given that I am logged in as an admin
And I am on the Change User page
"a new entry is saved in the database table" is vague, and too nuts-and-bolts for scenario language. Reword that to be specific and to say what's happening in business terms.