Last active
August 29, 2015 13:57
-
-
Save brianyoungblood/9690480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$casper awardspdf-casper.js [startpath] | |
var casper = require('casper').create(); | |
var _adminUser = ''; //drupal user | |
var _adminPass = ''; //drupal pass | |
var _baseURL = 'http://localhost:8080'; //no slash | |
var _loginPath = '/user'; | |
var _thenStartPath = casper.cli.get(0); //get start from first arg | |
var _saveCapturePath = '/tmp/awardspdf-casper'; //no slash | |
var _loginURL = _baseURL + _loginPath; | |
casper.clickWhileSelector = function(selector) { | |
return this.then(function() { | |
if (this.exists(selector)) { | |
this.echo('found link: ' + this.getElementInfo(selector).tag); | |
casper.captureSelector(_saveCapturePath + _thenStartPath + '/' + this.getElementInfo(selector).text + '.pdf', '#page',{ | |
format: 'pdf', | |
quality: 25 | |
}); | |
this.click(selector); | |
return this.clickWhileSelector(selector); | |
} | |
return this.echo('Done.').exit(); | |
}); | |
} | |
casper.start(_loginURL , function() { | |
this.fill('form#user-login', { | |
name: _adminUser, | |
pass: _adminPass | |
}, true); | |
casper.thenOpen(_baseURL + _thenStartPath, function() { | |
console.log('location is ' + this.getCurrentUrl()); | |
this.captureSelector('page.pdf', '#page'); | |
}); | |
}); | |
casper.clickWhileSelector('.next a').run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment