Ask a Question

How to pass parameters between steps in Cucumber with JS?

NhutHuynh
Occasional Visitor

How to pass parameters between steps in Cucumber with JS?

Hi guys, I have a small issue with Cucumber and I'm new to it, I have the scenarios below:

Scenario: 005 I can checkout successfully when entering valid information at required fields
When I enter first name into field First Name 
 
Scenario: 006....
And Order Information displays first name correctly
 
I had entered value in the first scenario and I want to pass that value into the 2nd scenario but don't know how
1 REPLY 1

Hi,

 

Did you had the opportunity to take a look here in the documentation? https://cucumber.io/docs/cucumber/state/

 

Caution, be careful when sharing state between scenarios. This is often consider bad practice, it can make your steps more tightly coupled and harder to reuse. It is always better to have stateless scenarios. Before / After hooks will add a little overhead on your test suite, but it keeps your tests stateless which is more sane and easier to maintain.

 

However, if you do need some data being shared, the World object is the one to use: https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/world.md

cancel
Showing results for 
Search instead for 
Did you mean: