src/page_objects/web/contacts/create/createContact.modal.js
import BaseContactFormPage from "./base.contactForm.js";
/** CreateContactModal
* @extends BaseContactFormPage
*/
class CreateContactModal extends BaseContactFormPage {
/**
* @param {args} args Args from controller
*/
constructor(args) {
super(args);
}
// PAGE ELEMENTS
/* eslint-disable require-jsdoc, max-len */
callingDetailsField() {
return this.element("input[name=sipUri]");
}
callingDetailsFieldErrorText() {
return this.element(
'//*[@name="sipUri"]/parent::*/descendant::*[contains(@class,"error")]'
);
}
callingDetailsFieldErrorExclamation() {
return this.element(
'//*[@name="sipUri"]/parent::*/descendant::*[contains(@class,"icon-exclamation")]'
);
}
/* eslint-enable require-jsdoc, max-len */
// PAGE FUNCTIONS
/**
* Fills form with provided parameters and clicks save button
* @param {String} name Name of contact
* @param {String} details Extension/sipUri of contact
* @param {Boolean} favorite Favorite for the contact
*/
async fillFormAndSave(name, details, favorite = false) {
await this.fillForm(name, details, favorite);
await this.clickSaveButton();
}
/**
* Fills form with provided parameters
* @param {String} name Name of contact
* @param {String} details Extension/sipUri of contact
* @param {Boolean} favorite Favorite for the contact
*/
async fillForm(name, details, favorite = false) {
await this.setNameField(name);
await this.setCallingDetails(details);
await this.setFavoriteField(favorite);
}
/**
* Clicks save button
*/
async clickSaveButton() {
await this.saveButton().click();
}
/**
* Set Calling details field in contact modal
* @param {String} details Calling details for the contact
*/
async setCallingDetails(details) {
await this.callingDetailsField().setValue(details);
}
/**
* Returns calling details field error text
* @return {String} Calling details field error text
*/
async getCallingDetailsFieldErrorText() {
return await this.callingDetailsFieldErrorText().getText();
}
/**
* Determines if error is visible in calling details
* @returns {Boolean} True if error is visible
*/
async isCallingDetailsFieldErrorVisible() {
return await this.callingDetailsFieldErrorExclamation().isVisible();
}
/**
* Get the calling details field limit via the HTML
* @returns {Integer} Value for calling details' "maxlength" attribute
*/
async getCallingDetailsFieldLimit() {
return await this.callingDetailsField().getAttribute("maxlength");
}
}
export default CreateContactModal;