Question

I'm using Casperjs/Phantomjs, to make a screenshot after I login on the forumwebsite. The code that I wrote gives this outcome in the cmd.

C:\xampp\htdocs\testing>casperjs screencappie.js
Var Declared
[info] [phantom] Starting...
Form FIlled
Clicked
Waited

I run the code with:

casperjs C:\path\path\..\test.js

I've set all environmental variables. It goes actually through all the code, but it seems it is not doing what should be done: making a screencapture.

The code I use:

var casper = require('casper').create({
    verbose: true,
    logLevel: 'debug'
});
var x       = require('casper').selectXPath;
var url     = 'http://forum.justforfun-gaming.com/newreply.php?tid=11178';
 console.log('Var Declared');
casper.start(url, function() {
   this.fill(x('//*[@id="content"]/table[2]/tbody/tr[2]/td/form'), {
        'username': 'USERNAME',
        'password': 'PASSWORD'
    }, true);
});
  console.log('Form FIlled');
casper.thenClick(x('//*[@id="content"]/table[2]/tbody/tr[2]/td/form/table/tbody/tr[4]/td/input'));
  console.log('Clicked');


casper.wait(5000, function() {
    this.capture('test.png', {
        top: 0,
        left: 0,
        width: 900,
        height: 900
    });
});
 console.log('Reached end of code');
Was it helpful?

Solution

Calling casper.run(); runs the whole suite of steps and optionally executes a callback when they’ve all been done. Obviously, calling this method is mandatory in order to run the Casper navigation suite. For examples and more info please read the documentation at http://docs.casperjs.org/en/latest/index.html

OTHER TIPS

Can you try this?

casper.capture('yourImage.png');

Instead of trying to resize. Make sure you are actually getting to the part of the screen capture before trying to take the picture.

I've run into this situation where it simply fails silently which is a real headache to deal with sometimes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top