File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Selects and clicks a tab element by its label text.
3+ *
4+ * This command finds a tab element within a tablist that contains the specified label text
5+ * and automatically clicks it to navigate to the tab. It requires a tabLabel parameter and
6+ * will throw an error if none is provided.
7+ *
8+ * @param {Object } options - The options object
9+ * @param {string } options.tabLabel - The text content of the tab to select
10+ * @returns {Cypress.Chainable } - A Cypress chainable element representing the selected tab
11+ * @example
12+ * // Select and click the "Details" tab
13+ * cy.tabs({ tabLabel: 'Details' });
14+ *
15+ * // Select, click, and verify the "Settings" tab content appears
16+ * cy.tabs({ tabLabel: 'Settings' })
17+ * .then(() => {
18+ * cy.get('.settings-panel').should('be.visible');
19+ * });
20+ *
21+ * // Select a tab and verify it has the active class after clicking
22+ * cy.tabs({ tabLabel: 'Properties' })
23+ * .should('have.class', 'active');
24+ */
25+ Cypress . Commands . add ( 'tabs' , ( { tabLabel = '' } ) => {
26+ if ( ! tabLabel ) {
27+ cy . logAndThrowError ( `tabLabel is required` ) ;
28+ }
29+ return cy . contains ( `ul[role="tablist"] [role="tab"]` , tabLabel ) . click ( ) ;
30+ } ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ import './commands/gtl.js';
4848import './commands/login.js' ;
4949import './commands/menu.js' ;
5050import './commands/stub_notifications.js' ;
51+ import './commands/tabs.js' ;
5152import './commands/throttle_response.js' ;
5253import './commands/toolbar.js' ;
5354import './commands/select.js' ;
You can’t perform that action at this time.
0 commit comments