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

394
Views
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 answers
Answer question

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 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!