Looking for an expander with its caption to click on it.
Successfully working:
cy.get('[caption="Radio Button"] > .expander-container').click();
Want to turn this into a command.
Cypress.Commands.add('findExpanderByName', (Caption: string) => {
cy.get('[caption=Caption] > .expander-container').click();
cy.wait(2000);
});
To use it:
cy.findExpanderByName("Radio Button");
However, it's not working because Caption is not being treated as a variable.
How can I get the value of the Caption variable in the command?