0

I want to pass an example with first step of all scenarios. But first step in all scenarios are same, just one element is different. So I want to all that step in background and want to add examples with background. In short suppose I want to navigate to facebook, twitter, google and youtube page and click on one element. Can I use following thing for that??

Background: Open the web-page
Given Open the <web_page> website
Examples:
|web_page|
|facebook|
|twitter|
|google|
|youtube|

Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...
Grasshopper
  • 8,908
  • 2
  • 17
  • 32
Jigar Patel
  • 21
  • 1
  • 4

2 Answers2

0

This looks odd requirement, however if you are using gherkin with qaf you can have it as below:

Background: Open the web-page
Given Open the <web_page> website


Scenario: ...
Examples:
|web_page|
|facebook|
|twitter|
|google|
|youtube|
Scenario: ...
Examples:
|web_page|
|facebook|
|twitter|
|google|
|youtube|
Scenario: ...
Examples:
|web_page|
|facebook|
|twitter|
|google|
|youtube|

With qaf you can also use external data-source outside feature file, for example:

Scenario: ...
Examples:Examples: {"dataFile":"resources/data/sitedata.csv"}

Scenario: ...
Examples:Examples: {"dataFile":"resources/data/sitedata.csv"}

Scenario: ...
Examples:Examples: {"dataFile":"resources/data/sitedata.csv"}

With BDD2 syntax you can have as below:

@dataFile:resources/data/sitedata.csv
Background: Open the web-page
    Given Open the <web_page> website

Scenario: ...

Scenario: ...

Scenario: ...
user861594
  • 5,733
  • 3
  • 29
  • 45
0

You shall be able to implement background with Data table as below -

Background: Open the web-page 
Given Open the <web_page> website
|web_page| 
|facebook| 
|twitter| 
|google| 
|youtube|

How to pass correct value of web page from Data table to step implementation method ?

There could be few ways doing so and one of them shall be check your scenarios name and based on that find corresponding value from Data table of web page to be loaded.

user861594
  • 5,733
  • 3
  • 29
  • 45
TheSociety
  • 1,936
  • 2
  • 8
  • 20
  • I don't think above example will iterate background and each scenario, instead it will pass data-table or map or list to the step as argument. – user861594 Mar 31 '19 at 15:02
  • It will open site for each scenario and take site name from Data table and we can do modifications as per our need. – TheSociety Mar 31 '19 at 15:28