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

Failed to enter full screen of video player #1213

Open
lawked opened this issue Jan 22, 2018 · 19 comments
Open

Failed to enter full screen of video player #1213

lawked opened this issue Jan 22, 2018 · 19 comments
Labels

Comments

@lawked
Copy link

lawked commented Jan 22, 2018

  • Operating System: mac OS High Sierra 10.13.2 (17C88)
  • Cypress Version: 1.4.1
  • Browser Version: Google Chrome 63.0.3239.132 (Official Build) (64-bit)

Is this a Feature or Bug?

bug

Current behavior:

Given a html video player
When I press the full screen button
Then the video player DOES NOT GO to full screen
...and then I can see the message in the console:
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

Desired behavior:

Given a html video player
When I press the full screen button
Then the video player SHOULD GO to full screen

How to reproduce:

1. open https://plyr.io/ or any other html video player
2. press full screen button

Test code:

describe('having video player in in-site mode', () => {
  it('should go to full screen after pressing full screen button', () => {
    cy.visit('https://plyr.io/');
    cy.get('[data-plyr="fullscreen"]').click();
  });
});

Additional Info (images, stack traces, etc)

I know the user gesture problem is really common, and this is the default browser behaviour, but it would be great to make it working correctly in Cypress as it should simulate user journey on tested page/application.

@dweight

This comment was marked as off-topic.

@jennifer-shehane
Copy link
Member

This is something that definitely requires our support of native browser events, as this cannot be done programatically: #311

@mightyiam
Copy link

Doesn't chromium have a CLI switch to bypass "API can only be initiated by a user gesture"?

@mightyiam
Copy link

I'm not fluent in C++. I've looked into Chromium code and I didn't find a way to bypass this check.

@JulienKode
Copy link

Does anyone have fix this issue ? or do you need help to investigate on this

@eirikb-bbc
Copy link

For now I am testing this by stubbing requestFullscreen and exitFullscreen, and asserting they are called when I expect them to be.

@missak-boyajian
Copy link

For now I am testing this by stubbing requestFullscreen and exitFullscreen, and asserting they are called when I expect them to be.

Can you show us how :)

@eirikb-bbc
Copy link

For now I am testing this by stubbing requestFullscreen and exitFullscreen, and asserting they are called when I expect them to be.

Can you show us how :)

This approach assumes you use getElementById to get the element you are calling requestFullscreen on, but it's a good starting point:

const stubFullscreenHandlers = (someDocument) => {
  cy.stub(someDocument, "fullscreenEnabled")
    .get(() => true)
    .as("doc:fullscreenEnabled");

  cy.stub(someDocument, "exitFullscreen").resolves().as("doc:exitFullscreen");

  const stubbedRequestFullscreen = cy.stub().resolves().as("requestFullscreen");

  const actualGetElementById = someDocument.getElementById;
  cy.stub(someDocument, "getElementById")
    .callsFake((elementId) => {
      const el = actualGetElementById.call(someDocument, elementId);
      el.requestFullscreen = stubbedRequestFullscreen;
      return el;
    })
    .as("doc:getElementById");
};

cy.document().then(stubFullscreenHandlers);

cy.visit(...)
// code making fullscreen request

@rmjjo
Copy link

rmjjo commented Mar 18, 2021

any update on this. I am stuck with my player testing in fullscreen. Thank you!

@arifozkan
Copy link

any update for testing full screen button

@arora239
Copy link

arora239 commented May 19, 2021

Hi all, I just came across this discussion, and I found one temporary solution till cypress comes up with something
https://github.com/dmtrKovalenko/cypress-real-events

Using .realHover() and .realClick() on the element, you can still go in full screen,
Works for me!

@poponuts

This comment was marked as off-topic.

@rehmanuet
Copy link

+1 for this feature. Currently, I used the real-event workaround but native implementation would be much better.

@nehamittal3012
Copy link

Waiting for this feature. Facing the same issue :
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.

@DenseMo23

This comment was marked as duplicate.

@andreifilip123
Copy link

Testing full screen is a need for us too

@nagash77 nagash77 added the prevent-stale mark an issue so it is ignored by stale[bot] label Apr 3, 2023
@przedab

This comment was marked as duplicate.

@Marim99
Copy link

Marim99 commented Feb 12, 2024

Hi all, I just came across this discussion, and I found one temporary solution till cypress comes up with something https://github.com/dmtrKovalenko/cypress-real-events

Using .realHover() and .realClick() on the element, you can still go in full screen, Works for me!

thanks a lot ! works for me

@jennifer-shehane
Copy link
Member

I ran across the docs recently on features gated by user activation and was reminded of this issue: https://developer.mozilla.org/en-US/docs/Web/Security/User_activation

We should be triggering a user activation event in order to more fully simulate browser behavior.

For the time being, using the https://github.com/dmtrKovalenko/cypress-real-events plugin to perform any action on the page (like clicking on a random div) should trigger user activation and make this full screen of the video player available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests