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

247
Views
No se puede seleccionar de autocompletar Cypress

la selección automática para el campo de autocompletar

 it('Test to grab the autocomplete values', ()=> { cy.visit('https://jqueryui.com/autocomplete/'); cy.get('#tags').type('c') cy.get('#ui-id-2').first().click() }) })

muestra que se hizo clic pero no se elige

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

0

Pude ver que hay un iframe, para tratar con iframe tienes que usar el código:

 cy.get('iframe.demoframe').its('0.contentDocument').its('body')

Entonces su código debería verse así:

 cy.visit('https://jqueryui.com/autocomplete/') cy.get('iframe.demo-frame') .its('0.contentDocument') .its('body') .find('#tags') .type('c') cy.get('iframe.demo-frame') .its('0.contentDocument') .its('body') .find('li') .first() .click()

Ahora, si desea condensar aún más su secuencia de comandos, puede usar los comandos personalizados de Cypress. Vaya a cypress/support/command.js y escriba:

 Cypress.Commands.add('getIframe', (iframe) => { return cy .get(iframe) .its('0.contentDocument.body') .should('be.visible') .then(cy.wrap) })

Y tu prueba será:

 cy.visit('https://jqueryui.com/autocomplete/') cy.getIframe('iframe.demo-frame').find('#tags').type('c') cy.getIframe('iframe.demo-frame').find('li').first().click()
about 4 years ago · Juan Pablo Isaza Report

0

Su código está básicamente bien, pero debe ejecutarlo dentro del iframe

 cy.visit('https://jqueryui.com/autocomplete/') cy.get('iframe.demo-frame') .its('0.contentDocument.body') .within(() => { cy.get('#tags').type('c') cy.get('#ui-id-2').first().click() cy.get('#tags').should('have.value', 'ActionScript') })
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!