question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress should allow fullscreen for AUT

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chaitanyajoycommented, Jul 6, 2022

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
1reaction
danshandocommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

viewport | Cypress Documentation
When hovering over each command, Cypress will automatically display the snapshot in the viewport dimensions that existed when that command ran. Defaults.
Read more >
Cypress: check if browser is in full screen mode - Stack Overflow
To check if Cypress is running on fullscreen you can get the viewport dimensions using Cypress.config and check if those are the same...
Read more >
Mar 23 2018 18:14 UTC - cypress-io/cypress - Gitter
Hello, When I start a test script, chrome opens maximized. Is there a wait to open it not full screen? I have not...
Read more >
Cypress - The Blue Book - GitHub Pages
Unit tests. Cypress can test anything that runs in a browser. Features⚑. Time Travel: Cypress takes snapshots as your tests run. Hover over...
Read more >
How to Get the First, or Nth Element in Cypress - Webtips
You can use the first and eq functions in Cypress in order to get the ... the first element in Cypress from a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found