percy / percy-capybara

Visual testing for Capybara with Percy.
https://docs.percy.io/docs/capybara
MIT License
45 stars 23 forks source link

Add support for iframes #7

Closed chrismaximin closed 8 years ago

chrismaximin commented 8 years ago

Note:

fotinakis commented 8 years ago

First, thanks for this! And for adding tests and all the things, this is great. Does it work when rendered in Percy? :)

Two quick thoughts (just at very quick glance, I will do a more thorough review this week):

  1. The ideal world is that this should be default, people shouldn't have to enable it — so that means part of SprocketsLoader (and, if you feel up to it, shared in NativeLoader as well—but I'm fine with not having support for it there as that is a less common path).
  2. Can you add a test for an iframe that is not on the same domain? Selenium often throws terrible errors for single-origin policy violations.
  3. Optionally, it should be safe/fast and potentially not require JavaScript. I just discovered a native Selenium method to switch context to the iframe — perhaps you can test out within_frame and see if it does what we want? Just need to find a way to get the source while within the frame context, and if Selenium has a native way to do that then it probably will let us dramatically simplify this code and probably not require JavaScript at all — http://stackoverflow.com/a/11910060/128597
chrismaximin commented 8 years ago

0- It does work when rendered in Percy! (example, root page has a black bg overlay) 1- I'll look into it for SprocketsLoader 2- I'll look into it. 3- I'll look into it. :)

chrismaximin commented 8 years ago

Updates: 1- Now integrated by default in SprocketsLoader and NativeLoader 2- Added same-origin domain check 3- Now using within_frame instead of evaluate_script to get iframe body

fotinakis commented 8 years ago

Back to you @christophemaximin, this is fantastic.

fotinakis commented 8 years ago

Thanks so much for contributing this.

Released as 2.3.0.pre.beta of the gem. Having a few customers test it out before tagging as 2.3.0.

chrismaximin commented 8 years ago

Thank you for your help and responsiveness! Love Percy, been looking for an easy-to-integrate service like that for years, as I've always believed in the crucial importance of integrated visual testing; so I'm happy to do what I can to help :)