【发布时间】: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