1

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')
Fody
  • 23,754
  • 3
  • 20
  • 37
Los
  • 147
  • 1
  • 11
  • That doesn't work, There should be no spaces for id, try adding `-_` or camelCase – Naren Apr 14 '22 at 23:03
  • This is not an application I made, it's one I'm trying to test externally for practice – Los Apr 14 '22 at 23:20

1 Answers1

3

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')
Fody
  • 23,754
  • 3
  • 20
  • 37