capybara-screenshot icon indicating copy to clipboard operation
capybara-screenshot copied to clipboard

Feature proposal: make it easier to customize screenshot names and paths

Open unmanbearpig opened this issue 9 years ago • 4 comments

Hi!

I'm wondering if anyone is interested in making it easier to customize screenshot names and paths, and if my idea fits the project at all or should I make my own gem.

So here is my problem:

I've noticed that I occasionally want to see how UI of a Rails app I'm working on looked at some particular revision, or which revision changed how the UI looks.

So I thought that I can utilize a CI service that I'm already using to make screenshots on each revision. I can make a small set of tests that would do nothing except visit particular pages that I care about, do some actions and make screenshots. I could use regular save_screenshot method for that, but I have to give it a full path, which is a bit annoying. And also, it looks like some Capybara drivers have different methods for making screenshots, so if I want to switch to different driver then I would have to change my code. It might also be useful to save HTML as well as an image. So I though that I could probably use capbara-screenshot.

There are a few problems though:

  • I can't provide a custom screenshot name to screenshot_and_save_page method.
  • I can't (?) use a different directory for my screenshot-making tests to avoid mixing up my failure screenshots with the screenshots from the screenshot-making tests.

So I can work on making that use case possible with capybara-screenshot if maintainers and users think it's not a bad idea.

Another idea

And while I'm at it, I think it might be (not sure though) more convenient to make folders in the screenshot directory for each RSpec example group.

For example if I have these specs:

describe "this" do
  describe "that" do
    it "does whatever"
  end
end

Then save screenshots in this/that/does_whatever. Optionally of course. Whould it be more convenient or not? What do you think?

In short

I'd like to know if it's useful to anybody (and appropriate in this gem) to implement these features:

  • Optional name argument for screenshot_and_save_page.
  • Make it easier to change screenshot path for particular tests.
  • (maybe, and optionally) Make the path reflect RSpec's example group structure.

I'd love to hear some feedback and contribute if it's useful.

unmanbearpig avatar Jan 01 '16 21:01 unmanbearpig

This is a nice idea indeed. I'd find this useful and would be happy to review your PR and help answer any questions you have.

mattheworiordan avatar Jan 19 '16 01:01 mattheworiordan

Thanks, @mattheworiordan! I don't have too much free time right now, so I've forked the project and made an issue there so I don't forget about it and this issue is not cluttering the list of open issues here.

unmanbearpig avatar Jan 20 '16 10:01 unmanbearpig

Can we re-open this? It's still an issue - and I would love to have this feature!

ssnyder avatar Oct 13 '17 18:10 ssnyder

@ssnyder sure, have reopened. Happy to review PRs / suggestions for this.

mattheworiordan avatar Oct 15 '17 16:10 mattheworiordan