Repository: bbc/wraith

Issue #441: Can't open phantom.js - double single quotes in path
Created: 2016-06-24T08:41:14Z
Hi there, I am losing my mind. My setup is vanilla wraith on Windows - I have tried running with all versions of Ruby. Every time I launch it outputs Can't open ''XXX:/Ruby22/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''  (note the double single quotes)
The file is definitively there! I even tried hardcoding it form inside wraith without success
How can I get out of this situation ?

YAML is valid
OUTPUT:
X:\XXX>wraith capture configs/capture.yaml -verbose
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
Can't open ''XXX:/Ruby22/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''


CONFIG:

##############################################################
##############################################################
# 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 'capture' mode, which is best suited to
# comparing a test and live version of the same website.
#
# `wraith capture capture.yaml`
#
##############################################################
##############################################################

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

# (required) The domains to take screenshots of.
domains:
  current:  "http://www.example.com"
  new:      "http://develop.example.com"

# (required) The paths to capture. All paths should exist for both of the domains specified above.
paths:
  home:     /
  about:    /about
  contact:  /get-in-touch

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

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

# (required) The directory that your 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

Duplicate issue #444: 'Can't open PhantomJS' error after upgrading PhantomJS from 1.9 to 2.0
Created: 2016-06-29T10:14:41Z
I have been successfully running wraith with PhantomJS 1.9 but when I upgraded PhantomJS to 2.0 I get an error message...
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
Nothing else has changed and if I switch back to 1.9 it starts working again.
Output...
D:\wraith>wraith history configs/alpha/individual_history.yaml
DEBUG: #################################################
DEBUG:   Command run:        history configs/alpha/individual_history.yaml
DEBUG:   Wraith version:     3.2.0
DEBUG:   Ruby version:       ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32]

DEBUG:   ImageMagick:        Version: ImageMagick 6.9.2-7 Q16 x64 2015-11-28 http://www.imagemagick.org

DEBUG:   PhantomJS version:  2.1.1

DEBUG:   CasperJS version:   Couldn't find nor compute phantom.casperPath, exiting.

DEBUG: #################################################
DEBUG:
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
DEBUG: phantomjs --ignore-ssl-errors=true 'C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js' 'https://localhost/web/individual/31621/profile/connections?step=profile_connections_direct' '1024x2000' 'alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png' 'body' 'false' 'D:/wraith/javascript/individual.js'
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
WARN: Failed to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png on attempt number 1 of 5
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
WARN: Failed to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png on attempt number 2 of 5
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
WARN: Failed to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png on attempt number 3 of 5
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
WARN: Failed to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png on attempt number 4 of 5
Can't open ''C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/wraith-3.2.0/lib/wraith/javascript/phantom.js''
WARN: Failed to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png on attempt number 5 of 5
ERROR: Unable to capture image alpha/individual_history_shotsx/profile_connections_direct/1024x2000_phantomjs_alpha2.png after 5 attempt(s)
WARN: Using fallback image instead

Config...
phantomjs_options: "--ignore-ssl-errors=true"

verbose: true

browser: "phantomjs"

mode: diffs_first

# Type the name of the directory that shots will be stored in
directory: 'alpha/individual_history_shotsx'  
history_dir: 'alpha/individual_history_shots_basex'

  # we've deliberately left out the snap_file

# Add only 2 domains, key will act as a label
domains:
  alpha2: "https://localhost/web"


#Type screen widths below, here are a couple of examples
screen_widths:
  - 1024x2000

#Type page URL paths below, here are a couple of examples
paths:
   profile_connections_direct:
     path: /individual/31621/profile/connections?step=profile_connections_direct
     before_capture: 'javascript/individual.js' 

#Amount of fuzz ImageMagick will use
fuzz: '20%'

Closing comment (2016-06-29T10:17:33Z): Thanks @SimonKeep, this looks similar to #441, it looks like PhantomJS 2+ doesn't like apostrophes in the command line.
This is a bug but I can't promise we'll be able to fix it anytime soon! Pull request fixes are welcome.