Search code examples
gherkinpageobjectscodeceptjs

PageObject passing in Stepfiles in CodeceptJS


I'm new to CodeceptJS and I need your help in understanding how to use BDD with CodeceptJS

Can we pass PageObjects in Step Definition file?

I'm able to pass it perfectly as shown below:

Scenario.only(‘login’, (I, loginPage) => {
loginPage.sendForm(‘john@doe.com’,‘123456’);
I.see(‘Hello, John’);
});

but it doesn't work while I try to pass the page Object in the stepdefinition file.

Given('I'm on the log in page', (loginPage) => {
  // From "features/basic.feature" {"line":8,"column":5}

    loginPage.sendForm(‘john@doe.com’,‘123456’);
    I.see(‘Hello, John’);

});

Can someone give an example of how step files, page objects and feature files interact?


Solution

  • Update: It worked when I used the 'require' statement