Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ManageIQ implements the following cypress extensions:
* `cy.getFormFooterButtonByTypeWithText({ buttonType, buttonText })` - retrieves form footer button by its name and type. `buttonText` is the name or text content of the button. `buttonType` is the HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'. e.g. `cy.getFormFooterButtonByType({buttonType: 'Reset', buttonText: 'reset'});`, `cy.getFormFooterButtonByTypeWithText({buttonText: 'Cancel'});`
* `cy.getFormInputFieldByIdAndType({ inputId, inputType })` - retrieves a form input field by its ID and type. `inputId` is the ID of the input field. `inputType` is the HTML input type (e.g., 'text', 'email', 'password'). Defaults to 'text'. e.g. `cy.getFormInputFieldByIdAndType({inputId: 'name'});`, `cy.getFormInputFieldByIdAndType({inputId: 'name', inputType: 'text'});`
* `cy.getFormLabelByForAttribute({ forValue })` - retrieves a form label associated with a specific input field by its 'for' attribute. `forValue` is the value of the 'for' attribute that matches the input field's ID. e.g. `cy.getFormLabelByForAttribute({forValue: 'name'});`
* `cy.getFormLegendByText({ legendText })` - retrieves a form legend element by its text content. Legend elements are typically used as captions for fieldset elements in forms. `legendText` is the text content of the legend element. e.g. `cy.getFormLegendByText({legendText: 'Basic Information'});`
* `cy.getFormSelectFieldById({ selectId })` - retrieves a form select field by its ID. `selectId` is the ID of the select field. e.g. `cy.getFormSelectFieldById({selectId: 'select-scan-limit'});`
* `cy.getFormTextareaById({ textareaId })` - retrieves a form textarea field by its ID. `textareaId` is the ID of the textarea field. e.g. `cy.getFormTextareaById({textareaId: 'default.auth_key'});`

Expand Down
19 changes: 19 additions & 0 deletions cypress/support/commands/element_selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ Cypress.Commands.add('getFormLabelByForAttribute', ({ forValue }) => {
return cy.get(`#main-content .bx--form label[for="${forValue}"]`);
});

/**
* Retrieves a form legend element by its text content.
*
* @param {Object} options - The options object.
* @param {string} options.legendText - The text content of the legend element (required).
* @returns {Element} The matched legend element.
* @throws {Error} If legendText is not provided.
*
* Example:
* cy.getFormLegendByText({ legendText: 'Personal Information' });
* cy.getFormLegendByText({ legendText: 'Payment Details' });
*/
Cypress.Commands.add('getFormLegendByText', ({ legendText }) => {
if (!legendText) {
cy.logAndThrowError('legendText is required');
}
return cy.contains('#main-content form legend.bx--label', legendText);
});

/**
* Retrieves a form select field by its ID using an object parameter.
*
Expand Down
Loading