https://cypress.io logo
Typing into an iframe
# i-need-help
m
Is this possible? I've tried a variety of ways and looked at some articles: https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/ https://medium.com/@michabahr/testing-stripe-elements-with-cypress-5a2fc17ab27b But none of them seem to work. Here's the iframe code I'm dealing with:
Copy code
<iframe name="__privateStripeFrame9846" frameborder="0" allowtransparency="true" scrolling="no" role="presentation" allow="payment *" src="https://js.stripe.com/v3/elements-inner-card-42fc15cfef40ae0d4764d99e5790c6a8.html#fonts[0][family]=Lato&fonts[0][fontSmoothing]=antialiased&fonts[0][src]=local(%22lato%22)%2C+local(%22Lato%22)%2C+url(%22https%3A%2F%2Fassets-sharetribecom.sharetribe.com%2Fwebfonts%2Flato%2FLato-Medium.ttf%22)+format(%22truetype%22)&fonts[0][__resolveFontRelativeTo]=https%3A%2F%2Fapp-staging.solace.health%2Ffindadvocates%2Ftom-marren%2F637051b3-685c-4785-88ac-368cb579b6c6%2Fcheckout&wait=false&mids[guid]=NA&mids[muid]=NA&mids[sid]=NA&style[base][fontStyle]=normal&style[base][fontSmoothing]=antialiased&style[base][fontSize]=16px&style[base][lineHeight]=22px&style[base][color]=%23101010&style[base][::placeholder][color]=%23%235A5A5A&style[base][padding]=30px&rtl=false&componentName=card&keyMode=test&apiKey=pk_test_51LIcjvG7JPMVzIHCacZxdETXWVq1iQXEcLzT3XCgPLoxl0P1jPGfQ82tqQxCrpH9uySUJFdH051pSVmbNHRe7Q5700ebwAoJ7j&referrer=https%3A%2F%2Fapp-staging.solace.health%2Ffindadvocates%2Ftom-marren%2F637051b3-685c-4785-88ac-368cb579b6c6%2Fcheckout&controllerId=__privateStripeController9841" title="Secure card payment input frame" style="border: none !important; margin: 0px !important; padding: 0px !important; width: 1px !important; min-width: 100% !important; overflow: hidden !important; display: block !important; user-select: none !important; transform: translate(0px) !important; color-scheme: light only !important; height: 24px;"></iframe>
e
There's different ways to handle iframes, but I just use this plugin: https://www.npmjs.com/package/cypress-iframe
m
I don't think that plugin works for multiple iframes
e
I use it for plaid tests that open multiple iframes in one test.
m
Ah figured it out, frameLoad is deceiving because it throws no errors if it doesn't find a frame.
5 Views