Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.02 KB

README.md

File metadata and controls

31 lines (22 loc) · 1.02 KB

Visual debugging for PhantomJS / CasperJS

This little hack is using a simple technique: It grabs the screen as PhantomJS or CasperJS sees it with captureBase64('png') and then it is POSTing the image into the receiving server which then sends it via socket.io to the browser which displays it is as inline image.

Here is how it works:

Setup

  1. Grab the repo (and node.js if you don't have it)
  2. run npm install
  3. run node server.js
  4. go to http://localhost:8001
  5. use the code below in your phantom or casper script to update the image:
this.evaluate( function(img){
  __utils__.sendAJAX("http://localhost:8001/", 'POST', {'img' : img }, false);    
  }, 
  {'img' : this.captureBase64('png')} 
);

OR you can attach it to onStepComplete handler

OR use setInterval to get a fresh screenshot every x ms - I'd recommend 150-300ms.

p.s. Remember to set the viewport size otherwise you can get the responsive, squeezed page.