Javascript casperjs评估未执行

Javascript casperjs评估未执行,javascript,web-scraping,phantomjs,casperjs,Javascript,Web Scraping,Phantomjs,Casperjs,我是casperjs新手,evaluate函数没有执行 casper.start('https://piedmont.taleo.net/careersection/2/moresearch.ftl?lang=en',function(){ casper.page.injectJs('/Users/manoj/apply_robots/jquery/jquery-2.1.4.min.js'); this.echo(this.getTitle()); this.wait

我是casperjs新手,evaluate函数没有执行

casper.start('https://piedmont.taleo.net/careersection/2/moresearch.ftl?lang=en',function(){

    casper.page.injectJs('/Users/manoj/apply_robots/jquery/jquery-2.1.4.min.js');
    this.echo(this.getTitle());

    this.wait(3000,processPage);
    this.echo("before processPage");

    });

    function processPage()
    {

        this.echo("inside processPage");
        var c = [];

        c = this.evaluate(getJ);
        this.echo(c);


    }

    function getJ(){
        this.echo("inside getJ");
        var jobs = [];
            var names = $('table#requisitionListInterface\\.listRequisition tr[id$=row]');
            __utils__.echo(names);

            for (var i = 0, row; row = names[i]; i++) {
                var $p = $.parseHTML(row.cells[1].innerHTML);
            }

            jobs.push(names);
            return names.length;


    }
大概

this.echo("inside getJ");
在您的例子中是问题所在,因为evaluate函数中的“this”不是casper对象,而是Window对象。 由于evaluate是在沙箱中执行的,所以它不会抛出错误


祝你好运

你知道如何从evaluate函数调用casperjs click吗?casper.evaluate(函数(原因){document.querySelector('#ctl00_Main_ctl00_btnUpdate_IdentityNotes1_txtReasonNotes')。value=reason;document.querySelector('#ctl00_Main_ctl00_btnUpdate_sb')。click(),config.reasonAutorize);最后一点是错误的。无法将
casper
对象传递到页面上下文中,因为它无法序列化。的可能重复