bigbluebutton-Github/bigbluebutton-tests/playwright/core/page.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

require('dotenv').config();
const { expect } = require('@playwright/test');
const parameters = require('./parameters');
const helpers = require('./helpers');
2021-11-18 04:07:14 +08:00
const e = require('./elements');
const { ELEMENT_WAIT_TIME } = require('./constants');
class Page {
constructor(browser, page) {
this.browser = browser;
this.page = page;
this.initParameters = Object.assign({}, parameters);
}
2021-11-19 04:09:29 +08:00
async init(isModerator, shouldCloseAudioModal, initOptions) {
const { fullName, meetingId, customParameter } = initOptions || {};
if (!isModerator) this.initParameters.moderatorPW = '';
if (fullName) this.initParameters.fullName = fullName;
this.meetingId = (meetingId) ? meetingId : await helpers.createMeeting(parameters, customParameter);
const joinUrl = helpers.getJoinURL(this.meetingId, this.initParameters, isModerator, customParameter);
await this.page.goto(joinUrl);
2021-11-19 04:09:29 +08:00
if (shouldCloseAudioModal) await this.closeAudioModal();
}
async closeAudioModal() {
2021-11-18 04:07:14 +08:00
await this.page.waitForSelector(e.audioModal);
await this.page.click(e.closeAudioButton);
}
async waitForSelector(selector, timeout = ELEMENT_WAIT_TIME) {
await this.page.waitForSelector(selector, { timeout });
}
async type(selector, text) {
await this.waitForSelector(selector);
const handle = await this.page.$(selector);
await handle.focus();
await handle.type(text);
}
async waitAndClick(selector, timeout = ELEMENT_WAIT_TIME) {
await this.waitForSelector(selector, timeout);
await this.page.focus(selector);
await this.page.click(selector);
}
}
2021-11-03 06:50:20 +08:00
module.exports = exports = Page;