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

73
Views
Cypress parece no poder encontrar ningún elemento dentro del iframe

Estoy tratando de acceder a los elementos dentro de mi iframe siguiendo los consejos enumerados en este artículo aquí , pero por alguna razón, Cypress no puede encontrar nada en el iframe.

Aquí está mi código de prueba

 describe('example to-do app', () => { const getIframeDocument = () => { return cy .get('iframe[data-cy="iframe"]') .its('0.contentDocument').should('exist') } const getIframeBody = () => { return getIframeDocument() .its('body').should('not.be.undefined') .then(cy.wrap) } it('finds the root', () => { cy.visit('http://localhost:3000/view') getIframeBody().get('#root'); }) });

Y este es mi iframe

<iframe data-cy="iframe" title="iframe" style={{ height: '100%', width: '100%' }} src={url} />

Finalmente esto es lo que tengo en mi cypress.json

 { "chromeWebSecurity": false }

Esto se basa en el artículo anterior. No estoy seguro de dónde me estoy equivocando.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar un complemento llamado cypress-iframe . Después de la instalación, vaya a cypress/support/commands.js y agregue lo siguiente:

 import 'cypress-iframe';

En su prueba puede usar directamente:

 cy.iframe('[data-cy="iframe"]').find('.some-button').should('be.visible').click() cy.iframe('[data-cy="iframe"]').contains('Some element').should('not.be.visible')
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!