Nabin Hait | 74b8c99 | 2021-04-15 11:30:55 +0530 | [diff] [blame] | 1 | // *********************************************** |
| 2 | // This example commands.js shows you how to |
| 3 | // create various custom commands and overwrite |
| 4 | // existing commands. |
| 5 | // |
| 6 | // For more comprehensive examples of custom |
| 7 | // commands please read more here: |
| 8 | // https://on.cypress.io/custom-commands |
| 9 | // *********************************************** |
| 10 | // |
| 11 | // |
| 12 | // -- This is a parent command -- |
| 13 | // Cypress.Commands.add("login", (email, password) => { ... }); |
| 14 | // |
| 15 | // |
| 16 | // -- This is a child command -- |
| 17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }); |
| 18 | // |
| 19 | // |
| 20 | // -- This is a dual command -- |
| 21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }); |
| 22 | // |
| 23 | // |
| 24 | // -- This is will overwrite an existing command -- |
| 25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }); |
Ankush Menat | bedb0ad | 2021-07-02 20:36:51 +0530 | [diff] [blame] | 26 | |
| 27 | const slug = (name) => name.toLowerCase().replace(" ", "-"); |
| 28 | |
| 29 | Cypress.Commands.add("go_to_doc", (doctype, name) => { |
| 30 | cy.visit(`/app/${slug(doctype)}/${encodeURIComponent(name)}`); |
| 31 | }); |