Reputation: 23
I have such user story:
Given I am on the 'Login page'
When I enter following credentials
|Email |Pass |
|email1|pass1|
|email2|pass2|
Then I get next 'Error' messages
|ErrorMessage |
|ErrorMessage1|
|ErrorMessage2|
How can this be done? The problem is that by my implementation, web driver is entering all the credentials from first table, and then try to assert error messages, but I need test to be run multiple times(kind of a loop).
Upvotes: 2
Views: 1844
Reputation: 32954
you need to use a scenario outline:
Scenario Outline: some name...
Given I am on the 'Login page'
When I enter the email <email> and password <password>
Then I get next the error message <errorMessage>
Examples:
| email | password | errorMessage |
| email1| pass1 | ErrorMessage1|
| email2| pass2 | ErrorMessage2|
this will run the same test twice, once for each row in the Examples
table. If you want the test to be run more times, just add more rows to the Examples
table
As was pointed out in the comments, Examples
is the defined term in gerkin, but Scenarios
or Examples
works fine in SpecFlow
Upvotes: 4