質問

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');
役に立ちましたか?

解決

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

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top