Home > OS >  Clicking on button in iframe in Cypress
Clicking on button in iframe in Cypress

Time:08-27

Ran into the issue, where the test code should click the button Process in the iframe. Used npm i cypress-iframe lib, but came up to nothing. Cypress could not find the button.

Tried cy.iframe('[]').find('resp-iframe[id="submit"]')

Image

Tried the other ways to click on iframe button:

cy.get('iframe[]').then($element => {
             const $body = $element.contents().find('body')
             cy.wrap($body).find('resp-iframe[]').eq(0).click();
         })

also

cy.get('[]').then($element => {
            const $body = $element.contents().find('body')
            let stripe = cy.wrap($body)
            stripe.find('[]').click(150,150)
          })

and

cy.iframe('#resp-iframe').find('[name="submitButton"]')

Error Error 2 Maybe anyone had something like that? Thanks.

CodePudding user response:

How about you try this:

cy.iframe('[name="AcsFrame"]').find('#submit').click()

CodePudding user response:

You don't need to repeat the resp-iframe inside the .find().

The selector .find('resp-iframe[id="submit"]') means look for HTML like this: <resp-iframe id="submit"> but the element you want is <input id="submit">.

Everything else looks ok

cy.iframe('[]').find('[id="submit"]')
  • Related