Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

396
Visualizações
how can i use find() in using xpath

i am trying a drag and drop in an iframe and to do that i need to pass xpath in find since i cant find a unique element to pass in cy.get()

currently i am trying

cy.xpath('//div[@class="unlayer-editor"]//iframe[@src]')
  .should("be.visible")
  .find('//div[@class = "blopockbder-coent-tols43 col-sm-12"]//div[@aria-describedby="t8ppy-tooltip-9"]')

but this isnt working

i am using cypress for automation

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Not an expert on xpath, but I think .find() can't be mixed with an xpath selector.

Two things to try

// chain 2nd xpath in place of .find()

cy.get('div[class="unlayer-editor"] iframe[id="my-iframes-id"]')
  .should("be.visible")
  .xpath('//div[@class = "blopockbder-coent-tols43 col-sm-12"]//div[@aria-describedby="t8ppy-tooltip-9"]')

or

// use .within() instead of .find() (roughly equivalent)

cy.get('div[class="unlayer-editor"] iframe[id="my-iframes-id"]')
  .should("be.visible")
  .within(() => {
    cy.xpath('//div[@class = "blopockbder-coent-tols43 col-sm-12"]//div[@aria-describedby="t8ppy-tooltip-9"]')
  })

Other things that might need adjusting

The iframe selection generally needs a follow-up command to get it's document body (ref Working with iframes)

// get the iframe document body any select within it

cy.get('div[class="unlayer-editor"] iframe[id="my-iframes-id"]')
  .its('0.contentDocument.body', { log: false }).should('not.be.empty')
  .within(() => {
    cy.xpath('//div[@class = "blopockbder-coent-tols43 col-sm-12"]//div[@aria-describedby="t8ppy-tooltip-9"]')
  })

Some of those classes in the path like col-sm-12 are purely display-oriented and may be different if you test at different devices. Once the test works, try removing them to make the test more robust.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda