Example Script (with video!)
Here’s an example of a simple script I whipped up. All this does is open Youtube in the browser, search for “Austin, Texas”, click on the second video and then pause it after it starts playing. (Since this is Youtube, there’s an advertisement that begins before the script pauses it)
Code for this script
/// <reference types="cypress" /> describe('Youtube Example', () => { // ********************************************************************************** it('Navigate to Youtube and search for a video', () => { cy.visit('https://www.youtube.com'); cy.get('[name="search_query"]') .focus() .type('Austin, Texas') .type('{enter}') .wait(1500) //Now look at the results and click the second video cy.get('[href="/watch?v=KzX9kJumv9A"]').eq(0) //play this specific video .click() .wait(2500) .get('[controlslist="nodownload"]').click() //pause the video by clicking on it }) //EOF })