Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- casper = require("casper").create({
- verbose: true,
- logLevel: 'debug',
- viewportSize: {
- width: 1920,
- height: 1080
- },
- pageSettings: {
- javascriptEnabled: true,
- userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36'
- }
- });
- casper.start('https://login.newrelic.com/login', function () {
- this.capture(content_dir + 'others/newrelic_login-page.png', { // works
- top: 0,
- left: 0,
- width: casper.evaluate(function () {
- return document.body.scrollWidth;
- }),
- height: casper.evaluate(function () {
- return document.body.scrollHeight;
- })
- }, {
- format: 'png',
- quality: 100
- });
- this.fill('form', {
- 'login[email]': '***',
- 'login[password]': '***'
- }, false);
- });
- casper.thenEvaluate(function () {
- document.querySelector('input[value="Sign in"]').click();
- });
- /**
- * New relic dashboard
- */
- casper.thenOpen('https://rpm.newrelic.com/accounts/123456/applications', function(){
- var self = this;
- this.wait(8000, function () {
- casper.evaluate(function () {
- localStorage.setItem('kioskNoir', 'false');
- });
- self.capture(content_dir + 'others/newrelic_dashboard.png', {
- top: 0,
- left: 0,
- width: casper.evaluate(function () {
- return document.body.scrollWidth;
- }),
- height: casper.evaluate(function () {
- return document.body.scrollHeight;
- })
- }, {
- format: 'png',
- quality: 100
- });
- });
- });
- /**
- * New relic Dashboard Crakrevenue
- */
- casper.thenOpen('https://insights.newrelic.com/accounts/123456/dashboards/12345?kiosk=true', function () {
- casper.evaluate(function () {
- localStorage.setItem('kioskNoir', 'false');
- });
- this.wait(8000, function () {
- this.capture(content_dir + 'others/newrelic_dashboard_product.png', {
- top: 0,
- left: 0,
- width: casper.evaluate(function () {
- return document.body.scrollWidth;
- }),
- height: casper.evaluate(function () {
- return document.body.scrollHeight;
- })
- }, {
- format: 'png',
- quality: 100
- });
- });
- });
- casper.on("resource.error", function(resourceError){
- console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
- console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
- });
- //Start casperJS
- casper.run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement