Skip to content

Commit d4c7bc0

Browse files
Update form button selector command to accept a wrapper-class argument
1 parent 3150287 commit d4c7bc0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cypress/support/commands/element_selectors.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
* @param {Object} options - The options object.
55
* @param {string} options.buttonText - The text content of the button (required).
66
* @param {string} [options.buttonType='button'] - The HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'.
7+
* @param {string} [options.buttonWrapperClass='bx--btn-set'] - The CSS class of the wrapper element containing the buttons. Defaults to 'bx--btn-set'.
78
* @returns {Element} The matched button element.
8-
* @throws {Error} If buttonName is not provided.
9+
* @throws {Error} If buttonText is not provided.
910
*
1011
* Example:
1112
* cy.getFormFooterButtonByTypeWithText({ buttonText: 'Save Changes' });
1213
* cy.getFormFooterButtonByTypeWithText({ buttonText: 'Submit', buttonType: 'submit' });
14+
* cy.getFormFooterButtonByTypeWithText({ buttonText: 'Cancel', buttonWrapperClass: 'custom-wrapper' });
1315
*/
1416
Cypress.Commands.add(
1517
'getFormFooterButtonByTypeWithText',
16-
({ buttonType = 'button', buttonText } = {}) => {
18+
({ buttonType = 'button', buttonText, buttonWrapperClass = 'bx--btn-set' } = {}) => {
1719
if (!buttonText) {
1820
cy.logAndThrowError('buttonText is required');
1921
}
2022
return cy.contains(
21-
`#main-content .bx--btn-set button[type="${buttonType}"]`,
23+
`#main-content .${buttonWrapperClass} button[type="${buttonType}"]`,
2224
buttonText
2325
);
2426
}

0 commit comments

Comments
 (0)