|
| 1 | +/* eslint-disable no-undef */ |
| 2 | + |
| 3 | +/** |
| 4 | + * Retrieves a form footer button by its name and type. |
| 5 | + * |
| 6 | + * @param {string} name - The name or text content of the button. |
| 7 | + * @param {string} [type='button'] - The HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'. |
| 8 | + * @returns {Element} The matched button element. |
| 9 | + * |
| 10 | + * Example: |
| 11 | + * cy.getFormFooterButtonByType('Save Changes'); |
| 12 | + * cy.getFormFooterButtonByType('Reset', 'reset'); |
| 13 | + */ |
| 14 | +Cypress.Commands.add('getFormFooterButtonByType', (name, type = 'button') => |
| 15 | + cy.contains(`#main-content .bx--btn-set button[type="${type}"]`, name) |
| 16 | +); |
| 17 | + |
| 18 | +/** |
| 19 | + * Retrieves a form input field by its ID and type. |
| 20 | + * |
| 21 | + * @param {string} inputId - The ID of the input field. |
| 22 | + * @param {string} [type='text'] - The HTML input type (e.g., 'text', 'email', 'password'). Defaults to 'text'. |
| 23 | + * @returns {Element} The matched input field element. |
| 24 | + * |
| 25 | + * Example: |
| 26 | + * cy.getFormInputFieldById('name'); |
| 27 | + * cy.getFormInputFieldById('name', 'text'); |
| 28 | + */ |
| 29 | +Cypress.Commands.add('getFormInputFieldById', (inputId, type = 'text') => |
| 30 | + cy.get(`#main-content .bx--form input#${inputId}[type="${type}"]`) |
| 31 | +); |
| 32 | + |
| 33 | +/** |
| 34 | + * Retrieves a form label associated with a specific input field by its ID. |
| 35 | + * |
| 36 | + * @param {string} inputId - The ID of the input field. |
| 37 | + * @returns {Element} The matched label element. |
| 38 | + * |
| 39 | + * Example: |
| 40 | + * cy.getFormLabelByInputId('name'); |
| 41 | + */ |
| 42 | +Cypress.Commands.add('getFormLabelByInputId', (inputId) => |
| 43 | + cy.get(`#main-content .bx--form label[for="${inputId}"]`) |
| 44 | +); |
| 45 | + |
| 46 | +/** |
| 47 | + * Retrieves a form select field by its ID. |
| 48 | + * |
| 49 | + * @param {string} selectId - The ID of the select field. |
| 50 | + * @returns {Element} The matched select field element. |
| 51 | + * |
| 52 | + * Example: |
| 53 | + * cy.getFormSelectFieldById('select-scan-limit'); |
| 54 | + */ |
| 55 | +Cypress.Commands.add('getFormSelectFieldById', (selectId) => |
| 56 | + cy.get(`#main-content .bx--form select#${selectId}`) |
| 57 | +); |
0 commit comments