Created
December 9, 2019 14:28
-
-
Save vincentchalamon/de9bbe4a5ee3faa78e8e448f74bf9320 to your computer and use it in GitHub Desktop.
Cypress.io: parse iframe content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.Commands.add('iframe', { | |
prevSubject: 'element', | |
}, $iframe => { | |
const contentWindow = $iframe.prop('contentWindow'); | |
return new Promise(resolve => { | |
if (contentWindow && contentWindow.document.readyState === 'complete') { | |
resolve(contentWindow); | |
} else { | |
$iframe.on('load', () => { | |
resolve(contentWindow); | |
}); | |
} | |
}); | |
}); | |
Cypress.Commands.add('getInDocument', { | |
prevSubject: 'document', | |
}, (document, selector) => Cypress.$(selector, document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: