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

569
Views
Unable to select item in cypress inside a frame

I have managed to log into a laboratory results system but I can't progress any further. My long term intention is to grab lab results for local incorporation into a medical record.

const getIframeBody = () => {
  // get the iframe > document > body
  // and retry until the body element is not empty
  return cy
  .get('frame[id="EclairMainFrame"]')
  .its('0.contentDocument.body').should('not.be.empty')
  // wraps "body" DOM element to allow
  // chaining more Cypress commands, like ".find(...)"
  // https://on.cypress.io/wrap
  .then(cy.wrap)
}

describe('Medlab Test', () => {
    it('Visits Eclair', () => {
      cy.visit('https://cdr.medlabcentral.co.nz/Eclair/mvc')
      cy.get('.login-field').eq(0).type('userid')
      cy.get('.login-field').eq(1).type('passphrase{enter}')
      cy.location('pathname').should('eq', '/Eclair/ClinicalWorkstation.aspx')
      getIframeBody().find('.search-form-form-textbox') 
    })
  }) 

This gets me logged in, but Cypress fails to find the input field to enter the Patient ID. I see the following error message:

Timed out retrying after 6000ms: Expected to find element: .search-form-form-textbox, but never found it. Queried from element: <body>

The DOM at this point for that input field shows:

<input class="search-form-form-textbox Mandatory" id="PatAliasId" name="PatAliasId" type="text" value="" tabindex="4">

enter image description here

I've tried cy.get on the class cy.get('.search-form-form-textbox'), on the id cy.get('#PatAliasId'), and on class attribute cy.get('name=["PatAliasId"]') but all these attempts time out at 6 seconds.

What's the correct syntax for finding a dom element inside a frame?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To work with frames in Cypress you have to install a cypress plugin with the following command, then you can interact with elements inside the frame

npm install -D cypress-iframe

Reference URL Cypress Frames

If you have done the above already, then load the frame first to find the required element

cy.frameLoaded(#frameId)
cy.iframe.find('#PatAliasId').type('abc')
about 4 years ago · Santiago Trujillo Report

0

In previous version of cypress, don't have any support for the iFrame. But in latest version cypress provided the support for iFrames.

Do work on cypress , we need to install cypress-iframe by using the below commands.

npm install -D cypress-iframe

Use this below code:

describe('Medlab Test', () => {
    it('Visits Eclair', () => {
      cy.visit('https://cdr.medlabcentral.co.nz/Eclair/mvc')
      cy.frameLoaded('#frameId')
      cy.iframe.find('#PatAliasId').type('Enter Your Input')
    })
  }) 
about 4 years ago · Santiago Trujillo 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!