How should I reuse Background or same given step in cucumber #631
Replies: 1 comment
-
Found a solution : added these steps in functions to get newTab's reference
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All, I am new to cucumber and have used this repo as base to build an automation framework. There is a particular case I am facing issue with and would appreciate some suggestions.
For my framework I am using Page Object Model design pattern and cucumber is primary test runner.
For my scenario -
I have a portal with option to manage catalog. Catalog page opens in a new tab when I click on a link in home page of portal. I handle this as following -
Now I have to use above steps in Given function for multiple features (not scenarios but features like download file, upload file, see logs etc) of Catalog page. Implementing same Given function in multiple step definition files results into multiple step definition match error.
If I implement Given function only once and try to use "newTab" further in When and Then in step definition files it gives error as newTab is undefined. i.e. newTab from StepDef1 can't be reused in StepDef2 file. If anyone has worked on similar problem, can you please advise -
How to handle such cases where same Background/Step has to be used in multiple feature files.
One suggestion I saw somewhere is to use hook : I am already using Before hook to initiate page and Before hook with tag to login to portal as below -
If a implement another Before hook with tags for these scenario to reach to catalog page - in that case will all before hooks run ? But then again how will I pass the newTab from Before hook to Given/When/Then ?
Beta Was this translation helpful? Give feedback.
All reactions