Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

zsxsoft-deprecated/phantomjs-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published