How do I enter data into a form input in an iframe using cypress?

后端 未结 8 1681
渐次进展
渐次进展 2021-02-05 14:01

I have been trying to test a stripe checkout form using cypress.io

If anyone has managed to get this to work please let me know. I found a thread on the matter here http

8条回答
  •  梦谈多话
    2021-02-05 14:32

    in order to avoid using:

    cy.wait(5000)
    

    I found a better way to do it following the instructions cypress provides in this tutorial about how to work with iframes

       cy.get('iframe[name="__privateStripeFrame5"]')
        .its("0.contentDocument.body")
        .should("not.be.empty")
        .then((body) => {
          cy.wrap(body)
            .find("[name=cardnumber]")
            .type("6011111111111117", { force: true });
       });
    

提交回复
热议问题