Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

416
Views
Click on element inside iFrame - Cypress

Can anyone, please assist in following:

Want to click element which resides on found iframe. Also, imported plugin import 'cypress-iframe'; in commands class. Code for founding iframe and clicking on element:

clickIFrameElement(elementCss, element1Css) {
    cy.frameLoaded(elementCss);
    cy.iframe(elementCss).find(element1Css).then(function(){
       cy.get(element1Css).click({ force: true })
    })
}

In test, I call this command:

cy.frameLoaded(elementCss).eq(0);
cy.iframe().find(element1Css).should('be.visible').click()

It does find iframe, but do not click on element. Error which get:

Timed out retrying after 20000ms: Expected to find element: #grouped-pageload-Banner button[class*="save-consents evSpAcceptBtn"], but never found it.

HTML for iframe: enter image description here

What I am doing wrong, or what is incorrect in code?

Thank you in advance

UPDATE

Tried also second approach with following command:

cy.iframe().find(#grouped-pageload-Banner button[class*="save-consents evSpAcceptBtn"]).should('be.visible').click()

But got second error:

cypress-iframe commands can only be applied to exactly one iframe at a time.  Instead found 7
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Please replace this line into your code

cy.iframe('#ifrmCookieBanner')
    .find('#grouped-pageload-Banner button[class*="save-consents evSpAcceptBtn"]')
    .should('be.visible')
    .click()

And put this in your support/index.js

Cypress.on('uncaught:exception', (err, runnable) => {
    // returning false here prevents Cypress from
    // failing the test
return false
})
about 4 years ago · Juan Pablo Isaza Report

0

Check if the iframe URL belongs to the same domain of current window, otherwise, this cannot be executed for security reasons. But if you have how to install a Chrome extension in user, this action can be performed via content_script ;)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!