mattheworiordan / capybara-screenshot

Automatically save screen shots when a Capybara scenario fails
MIT License
1.02k stars 168 forks source link

"Screenshot could not be saved. (...) No such file or directory" - tmp/capybara does not exist yet #227

Open marekciupak opened 6 years ago

marekciupak commented 6 years ago

Hi,

I've got the following error:

WARN: Screenshot could not be saved. An exception is raised: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /home/circleci/XXX/tmp/capybara/screenshot_2018-04-05-04-39-52.104.png>.

Here is my temporary solution:

# features/env.rb

# ....
Dir.mkdir(Capybara.save_path) unless Dir.exist?(Capybara.save_path)

I guess it would be good to fix the problem on the gem level.

Best, Marek

marekciupak commented 6 years ago

Ah, and there is one important thing when it comes to reproducing the issue :-)

The problem occurs only when the directory does not exist yet and you explicitly use:

Capybara::Screenshot.screenshot_and_open_image

When the test simply fails (without any usage of Capybara::Screenshot.screenshot_and_open_image), then the directory is created without problems and the screenshot is saved.