5
votes

How to parameterize tables in Specflow? Here is my feature file -

Feature: Login

As a User,
should land on ***** Login page
Enter valid Username and password
Home page displayed-Validate Logout link

Scenario: Successful login Given I am on **** Login page When I enter automation and autopassword Then the logout link should be displayed

Scenario: Successful parameterized Login
Given I am on **** Login page
When I enter:
| Username    | Password     |
| automation  | autopassword |
| misc        | misc123      |
Then the Logout link should be displayed

Here are my queries - I want to test a login using the second row values - misc & misc123. How can I call it using selenium? How can I make the parameterized part a complete scenario set- considering there are more scenarios after logging in? The test runs a complete feature with the first row and then execute the test logging in as second.

1
If you want to use multiple logins one by one then you can do keywork driver setup means get value from excel for username and pass and pass it to web page using selenium web driver code. OR you can create array and store value in that and then pass it for logins.Helping Hands
How do we integrate the feature file on specflow to get value from excel? Is it possible to keyword drive?ReuseAutomator
Please check all details here : ontestautomation.com/…Helping Hands
Hello Chan, if possible could you approve my answer?Mo H.

1 Answers

5
votes

Instead of using using a Table element, turn it into a Scenario Outline. So your Scenario would become.

Scenario Outline: Successful Login
Given I am on **** Login
When I enter <UserName> and <Password>
Then the logout link should be displayed

Examples: 
| UserName | Password |
| Foo      | Bar      |
| Bar      | Foo      |

This will run through each set of examples.