Add support for cy.get("&id") (translates to [cy-id="id"])

This commit is contained in:
mikiher 2024-04-29 08:03:10 +03:00
parent 6236f53b4f
commit ec83eb0a27

View File

@ -22,4 +22,10 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Cypress.Commands.overwriteQuery('get', function (originalFn, ...args) {
if (args.length > 0 && typeof args[0] === 'string' && args[0].startsWith('&')) {
args[0] = `[cy-id="${args[0].substring(1)}"]`
}
return originalFn.apply(this, args)
})