Files
gym-manage/gym-manage-uniapp/e2e/pages/CourseDetailPage.js
T

54 lines
1.2 KiB
JavaScript

/**
* 课程详情页 Page Object
*/
class CourseDetailPage {
constructor(miniProgram) {
this.mp = miniProgram;
}
async waitForReady() {
const page = await this.mp.currentPage();
await page.waitFor(2000);
console.log('课程详情页加载完成');
}
async getPath() {
const page = await this.mp.currentPage();
return page.path;
}
/**
* 点击预约按钮
*/
async clickBook() {
const page = await this.mp.currentPage();
const bookBtn = await page.$('.booking-btn');
if (bookBtn) {
// 检查按钮是否禁用
const disabled = await bookBtn.attribute('disabled');
if (disabled === 'true' || disabled === 'disabled') {
console.log('预约按钮已禁用(课程不可预约)');
return false;
}
await bookBtn.tap();
console.log('点击预约按钮');
return true;
}
console.log('未找到预约按钮');
return false;
}
async containsText(text) {
const page = await this.mp.currentPage();
const wxml = await page.wxml();
return wxml.includes(text);
}
async getPageData() {
const page = await this.mp.currentPage();
return await page.data();
}
}
module.exports = { CourseDetailPage };