Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for testing Picture-in-picture #8618

Open
staltz opened this issue Sep 18, 2020 · 8 comments
Open

Support for testing Picture-in-picture #8618

staltz opened this issue Sep 18, 2020 · 8 comments
Labels
type: feature New feature that does not currently exist

Comments

@staltz
Copy link

staltz commented Sep 18, 2020

Current behavior:

  • Implement a feature in the project where requestPictureInPicture is called
  • Write a Cypress test to run cy.get('.the-toggle-button').click()
  • In the test, include cy.document().its('pictureInPictureElement').should('not.equal', null)
  • Run the Cypress test
  • The should assertion fails and the following error shows in the console:
DOMException: Failed to execute 'requestPictureInPicture' on 'HTMLVideoElement': Must be 
handling a user gesture if there isn't already an element in Picture-in-Picture.

Desired behavior:

  • cy.document().its('pictureInPictureElement').should('not.equal', null) passes
  • No error is shown in the console

Test code to reproduce

I may edit this issue soon to give full reproduction assets, but for now, I know it's as simple as:

Versions

Cypress: 4.4.0
(Cypress) browser: Chrome 85
Operating system: Ubuntu 18.04.5 x86_64
Node: 10.15.3

@bahmutov
Copy link
Contributor

bahmutov commented Sep 18, 2020 via email

@bahmutov
Copy link
Contributor

bahmutov commented Sep 18, 2020 via email

@staltz
Copy link
Author

staltz commented Sep 18, 2020

Hey Gleb, thanks for the quick answer! I haven't tried the newest version. I could try

@staltz
Copy link
Author

staltz commented Sep 21, 2020

@bahmutov I ran the tests today in Cypress 5.2.0 and can confirm the bug (with the same symptoms) happens in 5.2.0 too.

Simple example test:

// ...
  it('picture-in-picture shows when the toggle button is pressed', () => {
    cy.document().its('pictureInPictureElement').should('equal', null)
    cy.get('.the-toggle-button').click()
    // The following assertion fails, but we want it to pass
    cy.document().its('pictureInPictureElement').should('not.equal', null)
  })
// ...

@sainthkh
Copy link
Contributor

Confirmed that it doesn't work.

it('t', () => {
  cy.visit('https://googlechrome.github.io/samples/picture-in-picture/')
  cy.document().its('pictureInPictureElement').should('equal', null)
  cy.get('#togglePipButton').click()
  // The following assertion fails, but we want it to pass
  cy.document().its('pictureInPictureElement').should('not.equal', null)
})

The problem is that the pictureInPicture element is created under the test runner, not AUT like below:

Screenshot from 2021-01-20 14-41-11

But I guess there might be no way to create it under the test runner.

@sainthkh sainthkh added stage: ready for work The issue is reproducible and in scope type: bug labels Jan 20, 2021
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jan 20, 2021

I would classify this as a feature request for Cypress to support testing Picture-in-picture in general. Right now, as sainthkh described, this is not working inside of Cypress. https://w3c.github.io/picture-in-picture/

@jennifer-shehane jennifer-shehane changed the title click() command is an invalid user gesture for requestPictureInPicture() Support for Picture-in-picture Jan 20, 2021
@jennifer-shehane jennifer-shehane added type: feature New feature that does not currently exist and removed type: bug labels Jan 20, 2021
@cypress-bot cypress-bot bot added stage: proposal 💡 No work has been done of this issue and removed stage: ready for work The issue is reproducible and in scope labels Jan 20, 2021
@jennifer-shehane jennifer-shehane changed the title Support for Picture-in-picture Support for testing Picture-in-picture Jan 20, 2021
@nehamittal3012
Copy link

waiting for this feature

@caiocampos-hotmart
Copy link

Hey guys, I had the same issue recently and was able to solve it temporarily using cypress-real-event. I'm not sure if it's the best way to do it, but for now it works.

it('Should show the picture in picture when the toggle button is pressed', () => {
  cy.document().its('pictureInPictureElement').should('equal', null);
  
  cy.getBySel('picture-in-picture-control').realClick();

  cy.document().its('pictureInPictureElement').should('not.equal', null);
});

@cypress-bot cypress-bot bot added stage: backlog and removed stage: proposal 💡 No work has been done of this issue labels Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

6 participants