Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cypress – Finding input element id when it as a space in it?

I’m trying to identify an input element within an iframe (I’m using the "cypress-iframe" library to account for this) by its ID so I can type in it but the input is "Mobile Phone" and Cypress throws an error when trying to look for it. There are other single word ids in the form that I can type in to just fine (so it’s not the iframe thankfully) but I’m wondering if there was a way to format the call to account for the space, current code below:

export function typeMobilePhone() {
    cy.wait(4000)
    cy.frameLoaded('#podium-modal')
    cy
        .iframe('#podium-modal')
        .find('#Mobile Phone')
        .click()
        .type('123456789')

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

As @Naren says, the space is killing your selector.

You can use an alternate selector (assuming you cannot change the id)

cy.iframe('#podium-modal')
  .find('[id="Mobile Phone"]')
  .type('123456789')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading