Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wraith latest mode failure #546

Closed
4 tasks done
juandelgado opened this issue Nov 15, 2017 · 6 comments
Closed
4 tasks done

Wraith latest mode failure #546

juandelgado opened this issue Nov 15, 2017 · 6 comments

Comments

@juandelgado
Copy link

Hello!

I'm trying to use Wraith in history mode but I've quickly run into an issue. The history step works well, but trying to run latest errors out. Relevant part of the error log:

Config validated. No serious issues found.
SAVING IMAGES
ERROR: No such file or directory @ rb_sysopen - shots/home/1280_chrome_news_latest.png
WARN: Using fallback image instead
/Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1289:in `initialize': No such file or directory @ rb_sysopen - shots/home/1280_chrome_news_latest.png (Errno::ENOENT)

I checked out the code and poking around found that calling setup_folders(config) before save_images(config, true) in lib/wraith/cli.rb ~L159 seems to sort the issue (command runs and can see expected results in the generated gallery).

Now, this is a total stab in the dark and I have no idea about possible ramifications, but thought of letting you know!

To reproduce:

  • Install latest Wraith (4.2.1) via gem install wraith and sufficiently new Chrome on Mac for headless mode (note doubt this is related to Chrome, but I don't want to install Phantom since it's been mostly abandoned).
  • On an empty folder copy YAML config below.
  • Run wraith history history.yaml.
  • Run wraith latest history.yaml.

Expected: commands run without problems, gallery is created.
Actual: latest command crashes, no gallery created.

Hope it helps.

Juan

ps: if adding that line of code is the right fix let me know and I'll send a PR over.


Issue checklist:

  • I have validated my config file against YAML Validator to make sure it is valid YAML.
  • I have run the wraith info command and pasted the output below:
DEBUG: #################################################
DEBUG:   Command run:        info
DEBUG:   Wraith version:     4.2.1
DEBUG:   Ruby version:       ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
DEBUG:   ImageMagick:        Version: ImageMagick 7.0.7-11 Q16 x86_64 2017-11-12 http://www.imagemagick.org
DEBUG:   PhantomJS version:  PhantomJS not installed
DEBUG:   chromedriver version:  ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2)
DEBUG:   CasperJS version:   Fatal: Did you install phantomjs?
DEBUG: #################################################
  • I have run the command in verbose mode (by adding verbose: true to my config) and pasted the output below:
DEBUG: #################################################
DEBUG:   Command run:        latest history.yaml
DEBUG:   Wraith version:     4.2.1
DEBUG:   Ruby version:       ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
DEBUG:   ImageMagick:        Version: ImageMagick 7.0.7-11 Q16 x86_64 2017-11-12 http://www.imagemagick.org
DEBUG:   PhantomJS version:  PhantomJS not installed
DEBUG:   chromedriver version:  ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2)
DEBUG:   CasperJS version:   Fatal: Did you install phantomjs?
DEBUG: #################################################
Config validated. No serious issues found.
SAVING IMAGES
ERROR: No such file or directory @ rb_sysopen - shots/home/1280_chrome_news_latest.png
WARN: Using fallback image instead
/Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1289:in `initialize': No such file or directory @ rb_sysopen - shots/home/1280_chrome_news_latest.png (Errno::ENOENT)
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1289:in `open'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1289:in `block in copy_file'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1288:in `open'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1288:in `copy_file'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:429:in `copy_file'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:356:in `block in cp'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1460:in `block in fu_each_src_dest'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1476:in `fu_each_src_dest0'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:1458:in `fu_each_src_dest'
	from /Users/juan/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/fileutils.rb:355:in `cp'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/wraith-4.2.1/lib/wraith/save_images.rb:169:in `create_invalid_image'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/wraith-4.2.1/lib/wraith/save_images.rb:88:in `rescue in block in parallel_task'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/wraith-4.2.1/lib/wraith/save_images.rb:79:in `block in parallel_task'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/parallel-1.12.0/lib/parallel.rb:486:in `call_with_index'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/parallel-1.12.0/lib/parallel.rb:342:in `block (2 levels) in work_in_threads'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/parallel-1.12.0/lib/parallel.rb:495:in `with_instrumentation'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/parallel-1.12.0/lib/parallel.rb:341:in `block in work_in_threads'
	from /Users/juan/.rvm/gems/ruby-2.4.1/gems/parallel-1.12.0/lib/parallel.rb:206:in `block (2 levels) in in_threads'
  • I have pasted the contents of my config file below:
##############################################################
##############################################################
# This is an example configuration provided by Wraith.
# Feel free to amend for your own requirements.
# ---
# This particular config is intended to demonstrate how
# to use Wraith in 'history' mode, which is best suited to
# making sure your site's appearance remains consistent over
# time.
#
# `wraith history history.yaml` # generate base screenshots
# `wraith latest history.yaml`  # take new shots and compare
#
##############################################################
##############################################################

# (required) The engine to run Wraith with. Examples: 'phantomjs', 'casperjs', 'slimerjs'
browser: "chrome"

# (required) The domain to take screenshots of.
domains:
  news: "http://www.bbc.com/news"

# (required) The paths to capture. This particular config is using casperjs, so we can take screenshots of selectors rather than the entire page.
paths:
  home: /

# (optional) JavaScript file to execute before taking screenshot of every path. Default: nil
# before_capture: 'javascript/wait--casper.js'

# (required) Screen widths (and optional height) to resize the browser to before taking the screenshot.
screen_widths:
  - 1280

# (optional) Resize to each screen width (efficient), or reload at each screen width (costly). Default: 'reload'
resize_or_reload: 'reload'

# (required for history mode, otherwise optional) The directory that your base screenshots will be stored in.
history_dir: 'shots_history'

# (required) The directory that your latest screenshots will be stored in
directory: 'shots'

# (required) Amount of fuzz ImageMagick will use when comparing images. A higher fuzz makes the comparison less strict.
fuzz: '20%'

# (optional) The maximum acceptable level of difference (in %) between two images before Wraith reports a failure. Default: 0
threshold: 5

# (optional) Specify the template (and generated thumbnail sizes) for the gallery output.
gallery:
  template: 'slideshow_template' # Examples: 'basic_template' (default), 'slideshow_template'
  thumb_width:  200
  thumb_height: 200

# (optional) Choose which results are displayed in the gallery, and in what order. Default: alphanumeric
# Options:
#   alphanumeric - all paths (with or without a difference) are shown, sorted by path
#   diffs_first - all paths (with or without a difference) are shown, sorted by difference size (largest first)
#   diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
# Note: different screen widths are always grouped together.
mode: diffs_first

# (optional) Choose to run Wraith in verbose mode, for easier debugging. Default: false
verbose: true

# (optional) Color to highlight the image diff. Default: 'blue'
highlight_color: red

# (optional) Parameters to pass to Phantom/Casper command line. Default: '--ignore-ssl-errors=true --ssl-protocol=tlsv1'
phantomjs_options: ''
@juandelgado juandelgado changed the title Wraith latest failure Wraith latest mode failure Nov 15, 2017
@superwese
Copy link

superwese commented Nov 20, 2017

Juan, you're right. This is related to browser: chrome, because chrome depends on the directories to be present. Adding setup_folders(config) in cli.rb doesn't break any tests.
You may also want to run wraith setup_folders /path/to/config.yaml manually before you run wraith latest /path/to/config.yaml

@superwese
Copy link

I pushed a docker image "superwese/wraith_chrome".
You may have a look at it:
https://github.com/superwese/wraith

@pivica
Copy link

pivica commented Dec 13, 2017

You may also want to run wraith setup_folders /path/to/config.yaml manually before you run wraith latest /path/to/config.yaml

Didn't work for me really, was getting bunch of errors when executing wraith latest history like

ERROR: No such file or directory @ rb_sysopen - shots/...

on saving images step and fatal error on the end.

Also manually executing steps like

wraith reset_shots history
wraith setup_folders history # missing step
wraith save_images history
wraith copy_base_images history
wraith crop_images history
wraith compare_images history
wraith generate_thumbnails history
wraith generate_gallery history

Is not working. I think because of a true parameter passed in save_images(config, true) in the method in wraith/cli.rb - you can't pass that parameter over wraith save_images cli command.

The only reliable way to make this work was to manually patch cli.rb as in 4f43aca.

@milodesc
Copy link

milodesc commented Mar 4, 2018

+1 on the solution above.

Adding setup_folders(config) to cli.rb worked for me.

@georgezee
Copy link

I came across the same problem.
Using superwese's fork that contains the abovementioned fix worked for me. Thanks.

@ChrisBAshton
Copy link
Contributor

Fixed in v4.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants