Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to add BeforeSuite / AfterSuite in CodeceptJS (webdriver) feature file? #3658

Unanswered
PavithraNavaneeth asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

@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
});
You must be logged in to vote
2 replies
Comment options

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 ?

Comment options

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.

Comment options

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

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /