src/page_objects/web/profile/profile.modal.js
import BasePage from "../../base.page.js";
/**
* ProfileModal
* @extends BasePage
*/
class ProfileModal extends BasePage {
/**
* @param {args} args Args from controller
*/
constructor(args) {
super(args);
}
// PAGE ELEMENTS
/* eslint-disable require-jsdoc */
settings() {
return this.element(
"button[class^=components-SettingsModal-SettingsModal__activeTab]"
);
}
myProfile() {
return this.element("span=My Profile");
}
changePasswordLink() {
return this.element(
"a[class^=components-SettingsModal-SettingsModal__passwordLink]"
);
}
/* eslint-enable require-jsdoc */
// PAGE FUNCTIONS
/**
* Open page for changing password
*/
async goToChangePassword() {
await this.changePasswordLink().click();
}
/**
* Extracting Extension from Change Password Link
* @returns {String} Extension number
*/
async getExtensionFromPasswordURL() {
const changePasswordUrl = await this.getChangePasswordUrl();
if (changePasswordUrl !== undefined) {
const extension = changePasswordUrl.match(/([\d]+)/g)[0];
return extension;
} else {
throw new Error("Extension URL is undefined.");
}
}
/**
* Fetching URL to check for changing password has the correct extension
* @returns {String} Href attribute of change password link
*/
async getChangePasswordUrl() {
return await this.changePasswordLink().getAttribute("href");
}
/**
* Open settings page
*/
async goToSettings() {
await this.settings().click();
}
/**
* Open my profile page
*/
async goToMyProfile() {
await this.myProfile().click();
}
}
export default ProfileModal;