Skip to content

Instantly share code, notes, and snippets.

@JohnMCrooks
Last active April 27, 2020 19:45
Show Gist options
  • Save JohnMCrooks/746f48d6ce80b487c0ad13cef02dd5c9 to your computer and use it in GitHub Desktop.
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.
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