File size: 1,668 Bytes
4d70170 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add('vueCheckInit', () => {
cy.get('.message .text').should('be.visible', { timeout: 10000 }).then((el) => {
expect(el.text()).to.include('Ready. Detected Vue')
})
cy.get('.instance').eq(0).contains('Root')
})
// Add iframe support until becomes part of the framework
Cypress.Commands.add('iframe', { prevSubject: 'element' }, ($iframe) => {
const get = selector => cy.wait(500).wrap($iframe.contents().find(selector))
const el = $iframe[0]
const iframeDoc = el.contentDocument || el.contentWindow.document
if (iframeDoc.readyState === 'complete') {
return Cypress.Promise.resolve({ body: $iframe.contents().find('body'), get })
}
return new Cypress.Promise((resolve) => {
$iframe.on('load', () => {
resolve({ body: $iframe.contents().find('body'), get })
})
})
})
|