GithubHelp home page GithubHelp logo

anthrax3 / flaming-octo-puss Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maciejjankowski/flaming-octo-puss

0.0 1.0 0.0 200 KB

Visual debugging for PhantomJS / CasperJS - allows you to see what the browser is rendering

Home Page: http://www.b-good.pl/2014/04/30/visual-debugging-for-casperjs-or-phantomjs/

JavaScript 43.26% HTML 56.42% Batchfile 0.31%

flaming-octo-puss's Introduction

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 - my preferred method:

setInterval(function(){
  show(casper);
}, 300);


function show(casper){
  casper.evaluate( function(img){
        __utils__.sendAJAX("http://localhost:8001/", 'POST', {'img' : img }, false);
      },
      {'img' : casper.captureBase64('png')}
  ); // evaluate
} // show

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

flaming-octo-puss's People

Contributors

foysalit avatar maciejjankowski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.