Javascript CasperJS返回导航不工作
这是我的代码,后面的导航不起作用,因为屏幕截图和前面的一样,尽管我等了2秒钟Javascript CasperJS返回导航不工作,javascript,web-scraping,phantomjs,casperjs,back,Javascript,Web Scraping,Phantomjs,Casperjs,Back,这是我的代码,后面的导航不起作用,因为屏幕截图和前面的一样,尽管我等了2秒钟 phantom.casperPath = "/Users/manoj/apply_robots/casjs/casperjs"; phantom.injectJs(phantom.casperPath + "/bin/bootstrap.js"); phantom.injectJs("/Users/manoj/apply_robots/jquery/jquery-2.1.4.min.js"); var utils =
phantom.casperPath = "/Users/manoj/apply_robots/casjs/casperjs";
phantom.injectJs(phantom.casperPath + "/bin/bootstrap.js");
phantom.injectJs("/Users/manoj/apply_robots/jquery/jquery-2.1.4.min.js");
var utils = require('utils');
var fs = require('fs');
var a;
var flag = 1;
var casper = require('casper').create();
casper.userAgent("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16");
var x = require('casper').selectXPath;
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.evaluate(function() {
document.querySelector('#requisitionListInterface\\.dropListSize').selectedIndex = 4;
return true;
});
this.wait(3000,function(){});
});
casper.then(function(){
this.thenClick(x('//*[@id="requisitionListInterface.pagerDivID4117.Next"]')).then(function() {
this.wait(2000,function(){
this.capture("i1.png");
});
});
});
casper.then(function () {
this.echo("inside back");
this.back();
this.wait(3000,function(){
this.capture("i3.png");
});
});
casper.then(function(){
this.thenClick(x('//*[@id="requisitionListInterface.pagerDivID4117.Next"]')).then(function() {
this.wait(2000,function(){
this.capture("i5.png");
});
});
});
有时需要执行两次
back()
调用才能使其工作:
casper.back().back();
我不知道为什么会出现这种情况,但它可能与重定向有关,这意味着当调用back()
时,将加载上一页,这只是对调用back()
的页面的重定向。再次调用back()
会在重定向页面之前加载页面