Online Training: Web test automation with CodeceptJS. Sign up now!

Another basic question of steps_file behavior

Hey guys,

Sorry for this question, but I’m trying to create a general method inside my steps_file, and from there, blow up errors to test on Scenarios.

It was my last attempt (but I’ve already tried other ways - :frowning_face: ):
It is inside step_file.js but there is a method calling it in a Page Object:

checkElementIsFreeze: async function (componentFreezeLocate) {
  let classAtribute = await this.grabAttributeFrom(componentFreezeLocate, 'class');
  await assert.ok(classAtribute.toString().indexOf('freeze') > -1).catch(() => this.say(`Component ${componentFreezeLocate} is not frozen`));
},

I know it’s easy for you @davert and @paulb:slight_smile:

When this method is on the Page Object works beautifully, without need to use try…catch…

We usually reply much faster in Slack https://join.slack.com/t/codeceptjs/shared_invite/enQtMzA5OTM4NDM2MzA4LWE4MThhN2NmYTgxNTU5MTc4YzAyYWMwY2JkMmZlYWI5MWQ2MDM5MmRmYzZmYmNiNmY5NTAzM2EwMGIwOTNhOGQ

  1. I would suggest to move this part to a custom helper, as this includes some logic of your own
  2. For this function you always need to use await when calling it: await I.checkElementIsFreeze
2 Likes