Reputation: 4328
I want to Execute a scenario twice based on number of rows in data tables from code shown in below structure -
testfeature.feature
Feature: Fill Form
@Test_Site_Registration
Scenario Outline: Verify the registration
Then Enter Text 'fName' <fname>
Then Enter Text 'mName' <mname>
Then Enter Text 'lName' <lname>
Then Submit
Examples:
| fname | mname | lname |
| FnameTest1 | FnameTest1 | FnameTest1 |
| FnameTest2 | FnameTest2 | FnameTest2 |
testfeature.rb
Then /^Enter Text (.*) (.*)$/ do |fieldId|value|
@browser.text_field(:id, fieldId).set(value)
end
Then (/^Submit$/) do
@browser.element(:xpath,"../../../btn-- a sample xpath").when_present.click_no_timeout
end
Here I want to execute the scenario "Verify the registration" twice, as I have been passing 2 different values in data tables.
Please Note- I already wrote 2 different scenarios and executed. However, for optimization and learning experience I want to know this answer.
Thank you in advance !!
Upvotes: 1
Views: 680
Reputation: 1485
You can try like this
Scenario Outline: Test Registration
Given Enter <fname>
Given Enter <mname>
Given Enter <lname>
Then Registration Process
Then Verify Registration
Examples:
|fname|mname|lname|
|f1|f1|f1|
|f2|f2|f2|
This means that, for every new data row in the examples, all the GIVEN, WHEN, THEN steps will be repeated.
Upvotes: 1