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.

Clicking buttons inside an iframe fails in headless Chrome only

See original GitHub issue

Current behavior:

Play/Pause buttons inside of the body of an embedded Youtube video on a webpage (in an iframe) are not found in headless Chrome 79 and test is failing. The same test passes in headless Electron 78 as well as headed Chrome 79 and headed Canary 81.

CypressError: Timed out retrying: Expected to find element: 'button[aria-label="Play"]', but never found it. Queried from element: <body.date-20200113.de_DE.ltr.exp-invert-logo.exp-kevlar-settings.exp-responsive.exp-search-big-thumbs.site-center-aligned.site-as-giant-card.webkit.webkit-537>

Desired behavior:

I know iframes are a bit of a murky area with Cypress, I just cannot figure out why there is a difference and the same test fails only in headless Chrome. Ideally the desired behavior would be the Play/Pause buttons to be found inside of the Youtube iframe body in headless Chrome.

Test code to reproduce

cy.visit('https://docs.cypress.io/guides/overview/why-cypress.html#In-a-nutshell')
  cy.get('iframe[title="youtube video"]').then(($iframe) => {
    const $body = $iframe.contents().find('body')
    cy.wrap($body).find('button[aria-label="Play"]').click()
    cy.wrap($body).find('button[aria-label="Pause (k)"]').click()
})

Versions

Cypress 3.8.1, Windows 10, headless Chrome 79

Screenshots

Failed test in headless Chrome 79: cmd_rJBhY6dx0s

Passed test in headless Electron 78: cmd_KftnodqORY

Passed test in headed Chrome 79: chrome_1I4joyyACV

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jan 15, 2020

@allwefly No worries, it’s not the first time I’ve seen locale differences with tests.

It’s usually good practice to set one in your tests. You can also set timezone for datetime variations as a machine environment variable like TZ=America/New_York cypress run.

0reactions
SonaliQAcommented, Aug 19, 2020

Well , i know this issue closed but i got the same error like you got at first time @jennifer-shehane
I have set “chromeWebSecurity” as false and have same code like allwefly Can you please tell me what i missed ?

image

cypress: 4.10.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to locate elements on webpage with headless chrome
have the headless browser take a screenshot. · 1 · Okay so I've found that the webpage isn't loading properly, and ends up...
Read more >
Issue 2198: ChromeDriver 2.34 doesn't wait until iframe ...
the only workaround is to wait X seconds between the switchTo() and any actual command inside the Iframe, or downgrade Chrome & chromedriver....
Read more >
iFrames in Selenium WebDriver - Tools QA
Selenium can only access the elements in a specific context, and the context of the main web page and the embedded iframe are...
Read more >
Puppeteer documentation - DevDocs
Puppeteer 7.1.0 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Read more >
Chrome Enterprise and Education release notes
From Chrome on iOS 108, it is easier for users to access their passwords. We have simplified the password list view, to show...
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