GithubHelp home page GithubHelp logo

alexandregz / casperjs-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mirovarga/casperjs-docker

0.0 3.0 0.0 116 KB

A Node.js module that runs CasperJS scripts in Docker containers

License: MIT License

JavaScript 89.81% Shell 10.19%

casperjs-docker's Introduction

casperjs-docker

A Node.js module that runs CasperJS scripts in Docker containers.

It is a slightly modified version of the one used by the casperbox.com service (now shut down).

Installation

Tested on Ubuntu 14.04.

  1. Install Docker

  2. Build the Docker image used to run CasperJS scripts in:

    $ sudo docker build -t ubuntu/14.04:casperbox .
    
  3. Edit the run-script-in-docker--password.sh file to update the sudo password

Usage

var casper = require('./casperjs-docker');
casper.runScript(
  "var casper = require('casper').create();\
  casper.start('http://casperjs.org', function() {\
    casper.echo('Hello, world!');\
  });\
  casper.run();",
  function(err, script) {
    console.log(script);
  }
);
{
  source: 'var casper = require(\'casper\').create();\ncasper.start(\'http://casperjs.org\', function() {\n  casper.echo(\'Hello, world!\');\n});\ncasper.run();\n',
  startedAt: 1434145107992,
  output: 'Hello, world!\n',
  finishedAt: 1434145111563
}

Scripts are run with CasperJS 1.1-beta3 and PhantomJS 1.9.7. If you'd like to use other versions feel free to modify the Dockerfile and rebuild the image.

Every script is automatically terminated after 30 seconds. If it's not enough for you feel free to modify the timeout in the casperjs-docker.js file (look for the maxScriptRunTime variable).

Testing

There are a couple of Mocha tests. If you're curious you can run them like this (the -t option is the test case timeout):

$ mocha -t 35000

There's also a blog post on my blog.

casperjs-docker's People

Contributors

mirovarga avatar

Watchers

 avatar  avatar  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.