3

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('[class="resp-iframe"]').find('resp-iframe[id="submit"]')

HTML of the problem

Tried the other ways to click on iframe button:

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

also

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

and

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

Error Error 2

Updated FYI: The first part of code - clicking the Google button in bottom-right:

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

First step

Then, waiting for secure payment preloader to finish up:

cy.wait(20000)

Preloader

Then, trying to catch the Process button by suggestions:

Secure page

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

or

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

whole code part looks:

const getIframeBody = () => {
            // get the iframe > document > body
            // and retry until the body element is not empty
            return cy
            .get('[id="popup-contentIframe"]')
            .its('0.contentDocument.body')
            // wraps "body" DOM element to allow
            // chaining more Cypress commands, like ".find(...)"
            // https://on.cypress.io/wrap
            .then(cy.wrap)
          }
      getIframeBody().find('[id="payWithout3DS"]').click()
      cy.wait(20000)
      cy.iframe('[name="AcsFrame"]').find('#submit').click()

But still, getting:

First attempt Second attempt

Maybe anyone had something like that? Thanks.

SimonB88
  • 31
  • 3

2 Answers2

0

How about you try this:

cy.iframe('[name="AcsFrame"]').find('#submit').click()
Alapan Das
  • 17,144
  • 3
  • 29
  • 52
0

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('[class="resp-iframe"]').find('[id="submit"]')
Fody
  • 23,754
  • 3
  • 20
  • 37