Inability to Select Menu Item in Cypress Test due ...
# i-need-help
a
When attempting to navigate to the Admin levels by selecting the 'Admin' menu item using the Cypress test, the following error occurs: "Timed out retrying after 10000ms: Cannot read properties of undefined (reading 'toLowerCase')". This issue is believed to be caused by a limitation encountered when trying to parametrize the string value from the BDD step down to the page element in the Cypress test. Steps to Reproduce: 1. Run the Cypress test with the following feature scenario:
Copy code
Feature: Admin Menu Navigation

     Scenario: Navigate to the Admin Levels
       When I select the 'Admin' Menu
2. Observe the Cypress Test Runner GUI. Expected Result: The 'Admin' menu item should be successfully selected without any errors, allowing navigation to the Admin levels. Actual Result: The test fails with a timeout error, indicating that properties of undefined cannot be read. This issue occurs when trying to locate the 'Admin' menu item using the
[label="Admin"]
selector. Additional Information: - The test code consists of the following files: - **testFile.js**:
Copy code
javascript
    When('I select the {string} Menu', (sideMenu) => {
      adminPageDefinitions.selectMenu(sideMenu);
    });
- **adminPageDefinitions.js**:
Copy code
javascript
    import adminPage from './adminPage';

    export const adminPageDefinitions = {
      selectMenu(sideMenu) {
        cy.get(adminPage.pageElements.sideMenu(sideMenu))
          .should('be.visible')
          .click();
      },
    };
- **adminPage.js**:
Copy code
javascript
    const adminPage = {
      pageElements: {
        sideMenu(sideMenu) {
          return cy.get(`[label="${sideMenu}"]`);
        },
      },
    };
- The error occurs at the line
cy.get(adminPage.pageElements.sideMenu(sideMenu)).should('be.visible').click();
in the
adminPageDefinitions.js
file. - Manually inspecting the page confirms that the menu item with the label "Admin" exists and is visible.