R
R
ruboss2015-10-15 07:24:56
JavaScript
ruboss, 2015-10-15 07:24:56

Why doesn't it enter the evaluate function in CasperJS?

Hello. There was a problem with CasperJS. Everything works until the moment when I want to fill a block on the page with text.

casper.thenOpen(url, function(){
    this.echo(this.getCurrentUrl());
    this.wait(5000, function() {
        this.click('div.someElem');
    });
});

casper.then(function(){
    this.evaluate(function(){ //сюда не заходит
        document.querySelector("div.anotherElem").innerHTML = someText;
    });
});

In evaluate simply does not come. I use the latest version of CasperJS, which I integrate into PhantomJS (v1.8). Who used Casper, tell me what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
druzh, 2016-06-25
@druzh

Paste this code before starting

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);
});

It will give you an error response from the server.
Add this here
var casper = require('casper').create({
  verbose: true,
  logLevel: 'debug',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question