Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Latest commit

 

History

History
34 lines (26 loc) · 923 Bytes

3.Context.md

File metadata and controls

34 lines (26 loc) · 923 Bytes

Context

Scenario Context

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.

> Next : Basic Commands to run the tests