bbc / wraith

Wraith — A responsive screenshot comparison tool

Home Page:http://bbc-news.github.io/wraith/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wraith fails on any URL containing "path", eg "/some-path"

fofr opened this issue · comments

commented

(This is using Wraith 4.0.1 on Ruby 2.3.1)

Any path in the config that contains the string "path" doesn't load correctly.

Found when trying to do a comparison of the valid URL:
https://www.gov.uk/drug-safety-update/corticosteroids-rare-risk-of-central-serous-chorioretinopathy-with-local-as-well-as-systemic-administration

Wraith was requesting:
https://www.gov.ukpath

It seems to error on anything containing the word "path", eg "/some-path"

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:

wraith info returns an error:

bundle exec wraith info
/usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.14.5/lib/bundler/rubygems_integration.rb:351:in `block (2 levels) in replace_gem': casperjs is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
	from /usr/lib/rbenv/versions/2.3.1/bin/casperjs:22:in `<main>'
bundler: failed to load command: wraith (/usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bin/wraith)
NoMethodError: undefined method `chomp' for nil:NilClass
  /usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/wraith-4.0.1/lib/wraith/helpers/utilities.rb:56:in `run_command_safely'
  /usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/wraith-4.0.1/lib/wraith/helpers/utilities.rb:36:in `list_debug_information'
  • I have run the command in verbose mode (by adding verbose: true to my config) and pasted the output below:
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
Loading https://government-frontend.herokuapp.compath at dimensions: 320x5000

Loading https://www.gov.ukpath at dimensions: 320x5000

Error with page https://government-frontend.herokuapp.compath

Error with page https://www.gov.ukpath

CROPPING IMAGES
COMPARING IMAGES
GENERATING THUMBNAILS
GENERATING GALLERY
bundler: failed to load command: wraith (/usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bin/wraith)
NoMethodError: undefined method `[]' for nil:NilClass
  /usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/wraith-4.0.1/lib/wraith/gallery.rb:124:in `block in sort_by_diffs'
  /usr/lib/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/wraith-4.0.1/lib/wraith/gallery.rb:122:in `each'
  • I have pasted the contents of my config file below:
---
browser: phantomjs
phantomjs_options: "--ignore-ssl-errors=true --ssl-protocol=tlsv1"
domains:
  production: https://www.gov.uk
  local: https://government-frontend.herokuapp.com
paths:
  drug_safety_update_2: "/drug-safety-update/corticosteroids-rare-risk-of-central-serous-chorioretinopathy-with-local-as-well-as-systemic-administration"
screen_widths:
- 320x5000
- 600x4000
- 1080x3000
resize_or_reload: resize
directory: shots
fuzz: 20%
threshold: 5
gallery:
  thumb_width: 200
  thumb_height: 200
mode: diffs_first
verbose: false

This is an old issue, so you've probably worked around it by now, but just for future reference because I came across it this morning and was a bit stumped. I think it's this line that causes a problem:

https://github.com/BBC-News/wraith/blob/7adfb1b365a913e46b9b6be408ef8f06185e0f20/lib/wraith/helpers/capture_options.rb#L50

You can work around it by swapping something like:

paths:
  some_page: /page?path=xyz

to:

paths:
  some_page:
    path: /page?path=xyz

I guess the ruby code should check options is a hash, otherwise you're potentially using the string's [] method which (TIL) accepts a match_str param: https://ruby-doc.org/core-2.3.0/String.html#method-i-5B-5D