How to pass parameters between steps in Cucumber with JS?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2021
01:04 AM
04-22-2021
01:04 AM
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
Labels:
- Labels:
-
Cucumber-js
1 REPLY 1
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2021
12:30 AM
04-23-2021
12:30 AM
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
