You can also try Googling “Cypress iframe” or something similar and you’ll probably find more in-depth articles dealing with the iframe testing process. You can add various exception handlers and logs which would help you through the build process in case iFrames start acting up (see “why not to do it” part above again). Note that this is just a basic example of how to do it. Try it out for yourself and see what happens. From there on, we’re wrapping this yield (Cypress rules) and using regular Cypress commands to access elements as if they’re regular HTML DOM elements. Whatever element we want to access in it, it has to be located in its body, just like with the regular HTML DOM in tests.Īfter getting the whole body content, we’re using Cypress’ then command to store the yield of the body in a variable. Once we’re in there, we’re going for its body (the final command in the first line). So, through its content document property you can access the iframe and its content as a regular document. I got the whole iframe element (get ‘iframe’ part), then I got its “contentDocument” property, which is explained quite well over here (really don’t want to get into that in this article): If you want to do multiple commands on the same iframe element, just add further cy.wrap() lines in the same block of code. If this didn’t stop you from doing it and your boss is yelling at your silly ideological reasons for leaving his/her app less than 100% automated, here’s the short way of doing it in pure Cypress:Īs simple as that. So, what you just did is that you tested someone else’s app for them (for free!) and they returned that favor by failing your release. The conclusion is pretty obvious: your tests are failing your build process and deployment because someone else’s app is not working properly and your tests are not aware of that (or could be if you ask them nicely). Therefore, if the iFrames fails on the third-party app side, it means that your code might be working correctly, but the iFrames code itself has critical bugs. Well, the main reason is that iFrames are basically someone else’s app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |