bbc / wraith

Wraith — A responsive screenshot comparison tool
http://bbc-news.github.io/wraith/
Apache License 2.0
4.84k stars 359 forks source link

URL's don't load through wraith - Failed to capture image shots #442

Closed theguythatrepeatedit closed 8 years ago

theguythatrepeatedit commented 8 years ago

Hi there, after having overcome the issue of https://github.com/BBC-News/wraith/issues/441, I am now stuck with a general WARN: Failed to capture image shots

I don't get any more information than that through the verbose logging. I have verified that phantomjs runs fine in isolation. But when running through wraith it will not load anything, I set up a proxy and saw no traffic leaving my machine at all. How can I debug this further ?

F:\wrth>wraith capture configs/capture.yaml
DEBUG: #################################################
DEBUG:   Command run:        capture configs/capture.yaml
DEBUG:   Wraith version:     3.2.0
DEBUG:   Ruby version:       ruby 2.3.0p0 (2015-12-25 revision 53290) [i386-mingw32]

DEBUG:   ImageMagick:        Version: ImageMagick 6.9.3-8 Q16 x64 2016-04-10 http://www.imagemagick.org

DEBUG:   PhantomJS version:  2.1.1

DEBUG:   CasperJS version:   CasperJS not installed
DEBUG: #################################################
DEBUG:
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.example.com/' '320' 'shots/home/320_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://develop.example.com/' '320' 'shots/home/320_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.example.com/' '600x768' 'shots/home/600x768_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://develop.example.com/' '600x768' 'shots/home/600x768_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.example.com/' '768' 'shots/home/768_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://develop.example.com/' '768' 'shots/home/768_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.example.com/' '1024' 'shots/home/1024_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://develop.example.com/' '1024' 'shots/home/1024_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/320_phantomjs_new.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_new.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
aCCCnWARN: Failed to capture image shots/home/768_phantomjs_new.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_current.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 2 of 5
WARN: Failed to capture image shots/home/320_phantomjs_new.png on attempt number 2 of 5
WARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 2 of 5
WARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_new.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
CCaanWARN: Failed to capture image shots/home/1024_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 3 of 5
ubygems☻.2.0gWARN: Failed to capture image shots/home/768_phantomjs_new.png on attempt number 2 of 5
eWARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 3 of 5
mswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithWARN: Failed to capture image shots/home/320_phantomjs_new.png on attempt number 3 of 5
javascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_new.png on attempt number 3 of 5
WARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
CWARN: Failed to capture image shots/home/1024_phantomjs_current.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js'''C:Ruby22lib
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 4 of 5
.WARN: Failed to capture image shots/home/768_phantomjs_new.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
2lWARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 4 of 5
tauonbmty.ogjmes.m'js's☻iejtnah vj'aa'svCca:rsRicuprbtiymp2yt2pmlhyiapbnh
'.'2
##############################################################
##############################################################
# 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
ChrisBAshton commented 8 years ago

Are you trying to take screenshots of http://develop.example.com? Because that doesn't exist, and will give an error.

Please reopen if this is not the case.

theguythatrepeatedit commented 8 years ago

Hi again, I don't know how I reopen - but the URL is not the problem, no connection will be made and all I have is the general WARN out - this is facebook and github

F:\wrth>wraith capture configs/capture.yaml
DEBUG: #################################################
DEBUG:   Command run:        capture configs/capture.yaml
DEBUG:   Wraith version:     3.2.0
DEBUG:   Ruby version:       ruby 2.3.0p0 (2015-12-25 revision 53290) [i386-mingw32]

DEBUG:   ImageMagick:        Version: ImageMagick 6.9.3-8 Q16 x64 2016-04-10 http://www.imagemagick.org

DEBUG:   PhantomJS version:  2.1.1

DEBUG:   CasperJS version:   CasperJS not installed
DEBUG: #################################################
DEBUG:
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.facebook.com/' '320' 'shots/home/320_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://github.com/' '320' 'shots/home/320_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.facebook.com/' '600x768' 'shots/home/600x768_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://github.com/' '600x768' 'shots/home/600x768_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.facebook.com/' '768' 'shots/home/768_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://github.com/' '768' 'shots/home/768_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.facebook.com/' '1024' 'shots/home/1024_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://github.com/' '1024' 'shots/home/1024_phantomjs_new.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_current.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/320_phantomjs_new.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 1 of 5
WARN: Failed to capture image shots/home/768_phantomjs_new.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/1024_phantomjs_new.png on attempt number 1 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/320_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/768_phantomjs_new.png on attempt number 2 of 5
WARN: Failed to capture image shots/home/1024_phantomjs_current.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/320_phantomjs_new.png on attempt number 2 of 5
WARN: Failed to capture image shots/home/600x768_phantomjs_new.png on attempt number 2 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubWARN: Failed to capture image shots/home/1024_phantomjs_new.png on attempt number 2 of 5
ygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
WARN: Failed to capture image shots/home/600x768_phantomjs_current.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
CCWARN: Failed to capture image shots/home/768_phantomjs_current.png on attempt number 3 of 5
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js''
a
ChrisBAshton commented 8 years ago

It looks like Phantom isn't running properly. To determine if this is the case, try running one of those commands you can see in debug mode, i.e.

ubygems☻.2.0gemswraith-3.2.0libwraithjavascriptmyphantom.js' 'http://www.facebook.com/' '320' 'shots/home/320_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
theguythatrepeatedit commented 8 years ago

.. OK I tried out a few things now Just to make sure - do you mean running the command like this ? C:\Ruby23\lib\ruby\gems\2.3.0\gems\wraith-3.2.0\lib\wraith\javascript>phantomjs phantom.js http://facebook.com/

Failed over and over until I found that the apostrophes in the arguments most likely is the problem - so this will fail:

C:\Ruby23\lib\ruby\gems\2.3.0\gems\wraith-3.2.0\lib\wraith\javascript>phantomjs phantom.js 'http://www.facebook.com/' '768' 'shots/home/768_phantomjs_current.png' 'body' 'F:/wrth/javascript/disable_javascript--phantom.js' 'false'
Loading 'http://www.facebook.com/' at dimensions: NaNx1500
Error with page 'http://www.facebook.com/'

And this will pass

C:\Ruby23\lib\ruby\gems\2.3.0\gems\wraith-3.2.0\lib\wraith\javascript>phantomjs phantom.js http://facebook.com/ 768 shots/home/768_phantomjs_current.png body F:/wrth/javascript/disable_javascript--phantom.js false
Loading http://facebook.com/ at dimensions: 768x1500
Snapping http://facebook.com/ at: 768x1500

:)

Is there something wrong with my system that makes it so intolerable to paths and apostrophes, a setting or something ?

I am glad to have found another cause of failure, but not sure how I can fix this globally ? do you know

theguythatrepeatedit commented 8 years ago

Oh lord, I finally made it! and I can not believe I'm the only one with this problem !? Maybe I'm the only one running Windows

Inside save_images.rb.construct_command - removed all variable apostrophes and hardcoded a new snapfile with double backslashes, like this:

snap = "C:\\Ruby23\\lib\\ruby\\gems\\2.3.0\\gems\\wraith-3.2.0\\lib\\wraith\\javascript\\phantom.js"
    command_to_run = "#{meta.engine} #{wraith.phantomjs_options} #{snap} #{url} #{width} #{file_name} #{selector} #{global_before_capture} #{path_before_capture}"

PHEW :) I can probably make a real fix later in the week if anyone is interested

ChrisBAshton commented 8 years ago

I know other Wraith users who run it on Windows, we've not seen this problem before. The quotes shouldn't affect it - and are needed in case you run in resize mode (in which case, width would be '320,624,1024', say... so inside the quotes, that's treated as one argument. Without quotes, it might be treated as several).

I'm also confused as to why you need to double backslash the snapfile path!

ChrisBAshton commented 8 years ago

Moving issue to #489.

Imlus commented 7 years ago

How is this not fixed yet? :) @theguythatrepeatedit you are a saver.

syamphaneendra commented 5 years ago

Hi, I have installed the below softwares and trying to run the wraith command in Windows 10. But i am facing the above mentioned issue. phantomjs --> 1.9.8 casperjs --> 1.1.4 ruby --> ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32] image magic 7.0.4 wraith --> 4.2.3

Could any one help me in sorting out this issue ?

syamphaneendra commented 5 years ago

Oh lord, I finally made it! and I can not believe I'm the only one with this problem !? Maybe I'm the only one running Windows

Inside save_images.rb.construct_command - removed all variable apostrophes and hardcoded a new snapfile with double backslashes, like this:

snap = "C:\\Ruby23\\lib\\ruby\\gems\\2.3.0\\gems\\wraith-3.2.0\\lib\\wraith\\javascript\\phantom.js"
    command_to_run = "#{meta.engine} #{wraith.phantomjs_options} #{snap} #{url} #{width} #{file_name} #{selector} #{global_before_capture} #{path_before_capture}"

PHEW :) I can probably make a real fix later in the week if anyone is interested

This fix is not worked for me in Windows 10. Could you please help me ?