-
-
Couldn't load subscription status.
- Fork 751
How to add BeforeSuite / AfterSuite in CodeceptJS (webdriver) feature file? #3658
-
Hello, I understand that codeceptjs does support beforesuite/aftersuite https://codecept.io/basics/#beforesuite for specific feature file. However when I try to add it my feature file - it doesnt work as expected.
for e.g: below is the sample of my feature file
Feature: Request account submission
Scenario Outline: Account to be created successfully
Given the user is logged in to explore my accounts
When the user selects CreateAccount
Then the page should show
Examples:
| xyz |
|123 |
how to add aftersuite here ? when I type in AfterSuite below the above examples, it shows unexpected element
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 2 replies
-
@PavithraNavaneeth Can you please share the code? Alternatively, you can try this https://codecept.io/internal-api/#concepts
import { event } from 'codeceptjs';
event.dispatcher.on(event.suite.before, (suite)=>{
//do something
});
Beta Was this translation helpful? Give feedback.
All reactions
-
Unfortunately I cant share the code here... Ill try to come up with some sample and post here.
Our structure looks like this:
feature file with scenario outlines and examples
Steps file (feature file statements are defined in steps.js)
step file calls methods from page file (page.js contains elements and actions)
could you please be more specific where to add this event dispatcher ? in codecept.conf file or in feature file ?
Beta Was this translation helpful? Give feedback.
All reactions
-
Please have a separate js or ts file and add the beforesuite/aftersuite code in that js file. Before the suite runs, the BeforeSuite method will be automatically called.
Beta Was this translation helpful? Give feedback.
All reactions
-
You reference to 'normal' Before hooks, but as I can see you are using Gherkin(first time I see someone uses it actually) so your reference is Gherkin
Beta Was this translation helpful? Give feedback.