【问题标题】:Include: dependency injection CodeceptJS/Puppeteer - Missing something?包括:依赖注入 CodeceptJS/Puppeteer - 缺少什么?
【发布时间】:2020-12-24 20:00:36
【问题描述】:

我显然遗漏了一些与 CodeceptJS 和 Puppeteer 的依赖注入相关的内容。我正在尝试关注文档,但尚未成功。

目标:创建一个页面对象类,从我的测试场景中访问该页面对象类中的方法。

简单的测试用例

Feature('Common logon/logoff scenarios');

Scenario.only('Test drawer class', (I, loginAs, menu) => {
    I.amOnPage('/login');
    loginAs('admin');
    menu.dashboard();
});

包含我的 codeceptjs.config.js 文件中的部分

  include: {
    I: "./steps_file.js",
    menu: "./src/fragments/menu.js"
  },

菜单页面对象类(menu.js)

const { I } = inject();

module.exports = {

  // Navigation drawer locators
  item: {
    dashboard: 'a[href="#/"]',
    admin: 'li[id="resources.admin.name"]',
    permissions: 'a[href="#/user-claims"]',
    sites: 'a[href="#/site"]',
    reportTemplates: 'a[href="#/reporttemplates"]',
    stations: 'a[href="#/station"]',
    supervisor: 'li[id="resources.supervisor.name"]',
    people: 'a[href="#/people"]',
    supervisorPressPallets: 'a[href="#/presspalletbuilder"]',
    stationIdentify: 'a[href="#/stationadopt"]',
    operator: 'li[id="resources.operator.name"]',
    operatorPressPallets: 'a[href="resources.operator.name"]'
  },

  // Methods to access nav drawer menu items
  dashboard() {
    I.click(this.item.dashboard);
  },

  admin() {
    I.click(this.item.admin);
  },
  
  permissions() {
    I.click(this.item.permissions);
  },

  sites() {
    I.click(this.item.sites);
  },

  reportTemplates() {
    I.click(this.item.reportTemplates);
  },

  stations() {
    I.click(this.item.stations);
  },

  supervisor() {
    I.click(this.item.supervisor);
  },

  people() {
    I.click(this.item.people);
  },

  supervisorPressPallets() {
    I.click(this.item.supervisorPressPallets);
  },

  stationIdentify() {
    I.click(this.item.stationIdentify);
  },

  operator() {
    I.click(this.item.operator);
  },

  operatorPressPallets() {
    I.click(this.item.operatorPressPallets);
  }
}

当我尝试运行测试时,出现以下错误

  1) Common logon/logoff scenarios
       Test drawer class:
     Cannot read property 'react' of undefined

对于我在这里所缺少的内容的任何帮助将不胜感激。

谢谢大家

鲍勃

【问题讨论】:

    标签: node.js puppeteer codeceptjs


    【解决方案1】:

    事实证明我的代码是正确的,这最终导致我的编辑器无法很好地处理代码完成,因此感兴趣的方法没有像我预期的那样显示。

    【讨论】:

      猜你喜欢
      • 2020-04-14
      • 2012-01-15
      • 1970-01-01
      • 2021-10-29
      • 2020-07-19
      • 2020-05-31
      • 1970-01-01
      • 2020-09-13
      • 2020-01-19
      相关资源
      最近更新 更多