0.0.1 • Published 9 years ago

phantomjs-promise v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Phantomjs-promise

Build Status NPM version

This's a library that promisify phantomjs-node. You don't need to install either phantomjs-node nor phantomjs. Require it, then it will Promises/A+ compliant.

Based on bluebird.

Usage

var phantom = require("phantomjs-promise");
phantom.createAsync().then(function (phantom) {
    return phantom.createPageAsync();
}).then(function (objects) {
    return objects.page.setAsync('viewportSize', {
        width: 100,
        height: 100
    });
}).then(function (objects) {
    return objects.page.openAsync("./test/test.html");
}).then(function (objects) {
    if (objects.ret[0] != "success") {
        throw objects.ret[0].status;
    }
    return objects.page.renderAsync(saveFileName); 
}).then(function (objects) {
    objects.page.close();
    objects.phantom.exit();
});

Test

mocha

License

The MIT License