문제

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