casperjs

Using $.ajaxStop() to determine when page is finished loading in CasperJS

狂风中的少年 提交于 2020-01-05 18:01:34
问题 So far in my tests written in CasperJS, I've been using waitForSelector() on page-specific elements to determine if a page has fully loaded (including all the async ajax requests). I was hoping to come up with a more standard way of waiting for page load and was wondering if the following was possible? Inject as clientscript the following (include.js) $(document).ajaxStop(function() { // Do something }) Description of ajaxStop according to jquery api: Register a handler to be called when all

Using $.ajaxStop() to determine when page is finished loading in CasperJS

有些话、适合烂在心里 提交于 2020-01-05 18:01:03
问题 So far in my tests written in CasperJS, I've been using waitForSelector() on page-specific elements to determine if a page has fully loaded (including all the async ajax requests). I was hoping to come up with a more standard way of waiting for page load and was wondering if the following was possible? Inject as clientscript the following (include.js) $(document).ajaxStop(function() { // Do something }) Description of ajaxStop according to jquery api: Register a handler to be called when all

CasperJS Evaluate function not returning Array

放肆的年华 提交于 2020-01-05 08:01:13
问题 Note, I've already looked at: Understanding the evaluate function in CasperJS I am trying to write a simple web-scraper to download all pdf's on my professor's webpage. Here is my code: var casper = require('casper').create({verbose: true , logLevel: "debug" }); var url = "https://www.cs.rit.edu/~ib/Classes/CSCI264_Fall16-17/assignments.html"; casper.start(url); var elements; try { casper.then(function(){ try { // statements elements = this.evaluate(function(){ return __utils__.findAll('body

CasperJS Evaluate function not returning Array

戏子无情 提交于 2020-01-05 08:01:12
问题 Note, I've already looked at: Understanding the evaluate function in CasperJS I am trying to write a simple web-scraper to download all pdf's on my professor's webpage. Here is my code: var casper = require('casper').create({verbose: true , logLevel: "debug" }); var url = "https://www.cs.rit.edu/~ib/Classes/CSCI264_Fall16-17/assignments.html"; casper.start(url); var elements; try { casper.then(function(){ try { // statements elements = this.evaluate(function(){ return __utils__.findAll('body

access the 'd' element from an SVG object with casperjs

核能气质少年 提交于 2020-01-04 09:14:07
问题 I am a very beginer in javascript/phantomjs/casperjs (like only several days of learning) but I am stuck with this svg graph I am trying to scrap data from. I am trying to access the d="M20,331.37,331.37,21.40...." element from an SVG object using a casperjs code, and write in the console and a txt file (or CSV). I try the following code: var casper = require('casper').create({ pageSettings: { loadImages: true, loadPlugins: true, userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit

CasperJS test coverage

我只是一个虾纸丫 提交于 2020-01-04 04:22:06
问题 Is it possible to get test coverage for casperJS tests? (Like istanbul or mocha-lcov). I googled a lot and could not find any official or unofficial coverage tool. 回答1: Look at this casper issue: https://github.com/gotwarlost/istanbul/issues/153 Currently Istanbul is recommended: https://github.com/gotwarlost/istanbul-middleware 来源: https://stackoverflow.com/questions/25229613/casperjs-test-coverage

How to get response status 404 in casper.js within thenOpen instead of undefined?

我与影子孤独终老i 提交于 2020-01-03 15:55:27
问题 Any idea why code below doesn't catch 404 in either response var or in the http.status.404 event? I run this with phantomjs 1.9, casperjs 1.0.2 and Windows 7 var casper = require("casper").create(), utils = require('utils'); casper.start(); casper.thenOpen('http://www.google.com/sadfafsdgfsd', function(response) { casper.capture('test.png'); utils.dump(response); }); casper.on('http.status.404', function(resource) { this.echo('wait, this url is 404: ' + resource.url); }); casper.run(function(

CasperJS, Page Stuck on Loading Screen

那年仲夏 提交于 2020-01-03 05:27:11
问题 I'm trying to use casperjs to grab a comment off of this page: http://www.regulations.gov/#!documentDetail;D=APHIS-2013-0013-0083 but when I navigate casper to it, it gets stuck on the 'loading' page. This is the image that I took using casper.capture(); My full code: var x = require('casper').selectXPath; casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); casper.start('http://www.regulations.gov/#!documentDetail;D=APHIS-2013-0013-0083'); casper.then(function () { casper

Is there a way to use Casperjs + Tor on windows?

核能气质少年 提交于 2020-01-03 04:34:12
问题 I've been searching for a while but can't figure it out. Is there a way to do this ? 回答1: Tor is socks5 proxy not normal proxy and it can work with casperjs , but you have to open tor first and make sure connection to tor network is done Then from command line use: casperjs --proxy=127.0.0.1:9150 --proxy-type=socks5 test.js If you closed tor application it's will lost the socks connection 来源: https://stackoverflow.com/questions/40144028/is-there-a-way-to-use-casperjs-tor-on-windows

Can use casperjs login to facebook but capture to png only show nav bar

大兔子大兔子 提交于 2020-01-02 08:09:15
问题 Can use casperjs login to facebook but capture to png only show nav bar this my code: facebook.js casper.start("http://www.facebook.com/login.php", function(response) { if (this.exists('[name="lsd"]')) { this.page.evaluate(function(a,b) { document.querySelector("input[name='email']").value = a document.querySelector("input[name='pass']").value = b; document.querySelector("#login_form").submit(); console.log("Login submitted!"); },user_email,user_pass); } else { this.echo('[name="lsd"] not