You can set SC
(Scenario Context) from any step definition.
step('set scenario context', ()=>{
SC.someVar = "some value"
})
step('check scenario context', ()=>{
console.log(SC.someVar) //some value
})
This helps to communicate between the steps. SC
reset for each scenario.
Scenario: Make an order from home page
Given I'm on home page
#Save order detail in scenario context
When I add following items in the cart
| pizza | Farm House |
| extra_toppings | onion,paneer |
#Validate the cart from the order detail in scenario context
Then I can see the cart with selected items
Scenario Context can be used to write
- generic steps and avoid writing vague, similar, technical steps.
- steps that can be used for different context, just like polymorphism.