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

Cypress should allow fullscreen for AUT #7776

Open
danshando opened this issue Jun 22, 2020 · 7 comments
Open

Cypress should allow fullscreen for AUT #7776

danshando opened this issue Jun 22, 2020 · 7 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this type: feature New feature that does not currently exist

Comments

@danshando
Copy link

danshando commented Jun 22, 2020

Current behavior:

I have a custom video player that I need to test the various elements of the player controls. Because the containing iframe for the site/app in the test runner does not have the allowfullscreen='true' attr. fullscreen features are semi or totally disabled. This is true for all browsers. I'm showing below with Youtube just to show it's not an isolated issue in my environment.

Desired behavior:

From what I can tell, simply adding the allowfullscreen='true' to the containing iframe (has class aut-iframe) will allow players (and other sites/apps that need to utilize fullscreen) to use and test features that utilize the fullscreen API.

Test code to reproduce

The tests below show the problem/solution in the firefox browser ran locally in the test runner (workaround doesn't work in ci environment for me). The behavior is similar in other browsers, but it was harder to hack fix in a concise way inside a test for demonstration purposes. In Chrome, for example, fullscreenEnabled is set to true, making the fullscreen button clickable, but the fullscreen action is still denied. I can mimic the same solution in chrome by manually adding the allowfullscreen attr. and then reloading the iframe via js in the console.

The first test fails because the fullscreenEnabled property is false. The second test will pass because I am programmatically adding the allowfullscreen attr., reloading the iframe, then running the tests.

describe('FAILS: firefox fullscreen is disabled', () => {
  it('should be able to use fullscreen', () => {
    cy.visit('https://www.youtube.com/embed/YE7VzlLtp-4');
    cy.document().its('fullscreenEnabled').should('be.true');
    // play video
    cy.get('.ytp-large-play-button').click();
    // click fullscreen button
    cy.get('.ytp-fullscreen-button').click();
    // check if the video actually went fullscreen
    cy.document().its('fullscreenElement').should('not.equal', null);
    // just to be nice, exit fullscreen and pause video
    cy.get('.ytp-fullscreen-button').click();
    cy.get('.ytp-play-button').click();
  });
});

describe('SUCCEEDS: firefox fullscreen is enabled via custom js', () => {
  it('should be able to use fullscreen', () => {
    cy.visit('https://www.youtube.com/embed/YE7VzlLtp-4');
    cy.window().then(window => {
      // get site iframe for site, set the allowfullscreen to true
      window.parent.document
        .getElementsByClassName('aut-iframe')[0]
        .setAttribute('allowFullScreen', 'true');
      // reload iframe
      window.location.reload();
      // make sure fullscreen is now enabled
      cy.document().its('fullscreenEnabled').should('be.true');
      // play video
      cy.get('.ytp-large-play-button').click();
      // click fullscreen button
      cy.get('.ytp-fullscreen-button').click();
      // check if the video actually went fullscreen
      cy.document().its('fullscreenElement').should('not.equal', null);
      // just to be nice, exit fullscreen and pause video
      cy.get('.ytp-fullscreen-button').click();
      cy.get('.ytp-play-button').click();
    });
  });
});

Versions

Cypress 4.8.0, Firefox 76/77 Beta.
Happens in both Mac OS 10.15.5 and Cypress Docker Image via Bitbucket Pipelines: cypress/browsers:node12.18.0-chrome83-ff77

@jennifer-shehane
Copy link
Member

I'm not able to reproduce this behavior as described. I'm running on a MacOS 10.15.5 with the default cypress.json - no changed viewportHeight or viewportWidth. Tried Firefox 72, 75, 76, 78, 79.

Can you provide a screenshot / failing test of the behavior you're seeing?

Chrome

Screen Shot 2020-06-23 at 2 32 04 PM

Firefox

Screen Shot 2020-06-23 at 2 32 48 PM

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jun 23, 2020
@danshando danshando changed the title Video Fullscreen Disabled in Firefox Fullscreen Mode Disabled in Firefox Jun 23, 2020
@danshando danshando changed the title Fullscreen Mode Disabled in Firefox Fullscreen Mode Disabled Jun 23, 2020
@danshando
Copy link
Author

@jennifer-shehane I've updated the OP. While I was poking around I discovered additional information and have updated title and description accordingly.

@jennifer-shehane
Copy link
Member

I'm not seeing this second test pass for me with the example provided in Chrome or Firefox. I believe the attribute should be all lowercase, although changing that doesn't make the test pass either.

I get what you're explaining now though and this would be a feature request.

The MDN docs describe allowfullscreen as legacy https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

This attribute is considered a legacy attribute and redefined as allow="fullscreen".

I'd like to see the passing test you've described. Am I missing something from the example?

@jennifer-shehane jennifer-shehane added the type: feature New feature that does not currently exist label Jul 10, 2020
@jennifer-shehane jennifer-shehane changed the title Fullscreen Mode Disabled Cypress should allow fullscreen for AUT Jul 10, 2020
@danshando
Copy link
Author

danshando commented Jul 13, 2020

Here's the test passing locally for me, when it flashes black is the video going fullscreen. I'm skipping the failing test here. This is Cypress 4.10, Firefox 77, macOS 10.15.5 :
ezgif com-optimize
It only works in Firefox, I can get it to work via console in Chrome, but I think Chrome is allowing the interaction probably because its from the console.

Regardless I think adding the fullscreen capability would be a great feature for cypress, not only for video player testing but for any other web app that utilizes fullscreen.

@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels Jul 14, 2020
jenniferarnesen added a commit to dhis2/dashboard-app that referenced this issue Jan 5, 2021
Adds fullscreen button to Visualization items

* No cypress tests added since it isn't currently possible to test the fullscreen api in cypress. I'll be keeping an eye on if/when this gets implemented in cypress (cypress-io/cypress#7776)
* Minor refactor: move check for whether to show ItemHeaderButtons (pluginIsAvailable) out of ItemHeaderButtons and to Item, so that the logic doesn't get too complex in ItemHeaderButtons (would have been first checking pluginIsAvailable, then checking the fullsreen prop)
dhis2-bot added a commit to dhis2/dashboard-app that referenced this issue Jan 5, 2021
# [31.4.0](v31.3.1...v31.4.0) (2021-01-05)

### Features

* add fullscreen option to visualization items [DHIS2-9879] ([#1358](#1358)) ([746d7b0](746d7b0)), closes [cypress-io/cypress#7776](cypress-io/cypress#7776)
@chaitanyavaddi
Copy link

In my case, I need to click a button to make my document display in full-screen mode. In Cypress, I end up in Unhandled Rejection (TypeError): fullscreen error

Screenshot 2022-07-06 at 4 17 48 PM

Screenshot 2022-07-06 at 4 16 52 PM

@serovpa
Copy link

serovpa commented Sep 5, 2022

i've faced the same issue after cypress clicks the 'fullscreen mode' button, besides fullscreen mode is turned on
cypress version 10.6.0
Screenshot 2022-09-05 at 18 01 31

@sikaili99
Copy link

I ended up using Cypress real events but again I faced one challenge, I couldn't get out of full screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

5 participants