Last active
April 27, 2020 19:45
-
-
Save JohnMCrooks/746f48d6ce80b487c0ad13cef02dd5c9 to your computer and use it in GitHub Desktop.
Using Cypress.io, The goal is to let a video play to a certain point then continue with whatever the rest of the test script needs. Trying to figure out how how to use properties in combination with aliases appropriately.
This file contains hidden or 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
letVideoPlayToXPercent(percent: number = 0.25, detectLoop?: boolean) { | |
cy.get(selectors.VIDEO_ELEMENTS) | |
.first() | |
.as('targetVideo') | |
.invoke('prop', 'currentTime') | |
.as('currentTime') | |
.get('@targetVideo') | |
.invoke('prop', 'duration') | |
.as('duration') | |
.then((duration) => { | |
var targetTime = duration * percent; | |
cy.log( | |
`Current time: ${'@currentTime'}, duration: ${duration}, target Time: ${targetTime}`, | |
); | |
while (targetTime > '@currentTime') { | |
cy.log('Target Time is still greater than current time'); | |
letVideoPlayToXPercent(percent); | |
} | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment