casperjs click()一个表单元素提交,等待,在下一页运行查询?

我想点击提交按钮,等待下一页加载,然后在第二页获取html.我做开始,然后运行,但是第一页仍然运行.有任何想法吗?
var casper = require('casper').create();
var site = 'http://www.example.com';
var data = {}; 

casper.start(site,function() {
     this.evaluate(function() {
        $('input[type="submit"]:first').click();
    }); 
});

casper.then(function() {
    data.body = this.evaluate(function() {
        var rows = $('#content table:first tbody tr');
        var listings = rows.eq(3).text();
        var count = rows.eq(4).text();
        return {
            listings: listings,count: count
        };  
    }); 
});

casper.run(function() {
    this.echo(data.body.listings);
    this.exit();            
});

解决方法

这只是部分解决了您的问题,但您可以使用waitFor确认您已经进入第二个页面.例如:
this.waitFor(function check() {
    return (this.getcurrenturl() === PAGE_2_URL);
},function then() { // step to execute when check() is ok
    this.echo('Navigated to page 2','INFO');
},function timeout() { // step to execute if check has Failed
    this.echo('Failed to navigate to page 2','ERROR');
});

相关文章

vue阻止冒泡事件 阻止点击事件的执行 <div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些