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

后端 未结 8 1795
渐次进展
渐次进展 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:09

    The iframe workflow is still pretty clunky (until this feature is implemented). For now, you can try forcing pretty much every DOM interaction:

    cy.visit("https://jsfiddle.net/1w9jpnxo/1/");
    cy.get("iframe").then( $iframe => {
    
        const $doc = $iframe.contents();
        cy.wrap( $doc.find("#input") ).type( "test", { force: true });
        cy.wrap( $doc.find("#submit") ).click({ force: true });
    });
    

提交回复
热议问题