casperjs

CasperJS click() doesn't load new html

和自甴很熟 提交于 2019-12-07 04:15:02
问题 I'm trying to use CasperJS' click() to follow a link which generates a modal on the current screen. When I query the proper selector and click it in the browser console using document.querySelector().click() it works, but even when I casper.evaluate() this it doesn't work. I found someone who had a very similar problem, but his question remains unanswered, and I am experiencing almost identical problems. casperjs button click doesn't navigate to next page the code I'm currently using is this

Web scraping with CasperJS returns strange error that isn't documented

蹲街弑〆低调 提交于 2019-12-07 02:13:38
问题 I wrote an web scraping script with CasperJS and it works perfectly on Mac OS 10.10.4 with CasperJS version 1.1.0-beta3 and PhantomJS version 1.9.8, but when I put the same script on one of my servers which is Ubuntu 14.04 (running inside Docker container) with the same environment (CasperJS and PhantomJS all the same versions) it suddenly just outputs this: I'm `fs` modules Which is pretty strange. One of my suggestion is that in this script I am also trying to require some other scripts

Set cookie for request in CasperJS

我只是一个虾纸丫 提交于 2019-12-07 00:37:41
问题 I want to load a page using CapserJS, but how can I send cookie which was exported from chrome's http request header at that page? Such as: "SUB=_2AkMjHt3gf8NhqwJRmPkQzG_qZIp_yA3EiebDAHzsJxJTHmMJ7IUyLkMN2K7WzRJvm-Tv3YY0xyZo; SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9WhCT_2hbJ1W1Cc4xfF-mFPo;" 回答1: There are multiple ways, but the easiest would be to use the page.addCookie or phantom.addCookie functions which PhantomJS provides, but you would have to set the domain (and path). Keep in mind that

How to write own CasperJS modules?

老子叫甜甜 提交于 2019-12-06 21:28:23
问题 For example, I have a step that often needs to be executed, eg user login before some test. How to write reusable chunks of code for CasperJS? Their documentation for extending CasperJS is written only for one file... Thanks! 回答1: Here's a simple approach. If not familiar with coffeescript, convert it to JS over at js2coffee. tests/casper/test.coolPage.coffee loginModule = require("./test.login") loginModule.login("test","testPW") casper.test.comment "Testing cool stuff, should be logged in

communication between Node/Express and Spooky/Casper js

孤人 提交于 2019-12-06 15:59:21
问题 I tried to incorporate node/express with spooky js. However, I wasn't able to send back the elements I retrieved using spookyjs. Below is my code. With my code, I only got foo printed out although I intended to get all the DOM elements data with spooky. I was wondering if anyone has the experience how this can be done? Thanks in advance! server.js var express = require("express"); var site = express.createServer(); var fill = require('./spooky_fill.js'); site.use(express.static(__dirname + '/

Unable to download .zip file from url with casperjs

六月ゝ 毕业季﹏ 提交于 2019-12-06 15:48:53
I've been trying to download a .zip file from a website using casperjs but it won't let me. 1) If I open the url with casper.thenOpen() it shows me the typical download dialog "Do you want to Open or save this file?", the thing is that I haven't been able to find a way to choose "Download it" (which is what I need) instead of "open it" with casperjs. 2) Right now I'm using casper.download() but it just downloads a 0 byte file, I think it's a better option because I can specify an address where the file is gonna be downloaded to and it doesn't ask me to download the file, it just download it

phantomjs with nohup not working

痴心易碎 提交于 2019-12-06 13:54:05
问题 I was trying to run phantomjs script via ssh using nohup command . But nohup threw an error which i found in nohup.out file. My command was --> nohup phantomjs example.js & phantomjs example.js run perfectly without nohup . I have also created a bash script to run this command with nohup but both time, I got this error --> events.js:72 throw er; // Unhandled 'error' event ^ Error: EBADF, read ** code of example.js var page = require('webpage').create(), system = require('system'), address,

Loop of test suites in a CasperJS test file results in random failures in the shell

浪子不回头ぞ 提交于 2019-12-06 10:31:34
问题 I would like check the title of several website. So, when I want do that with the "test object", I randomly get different results. I mean, when I run the shell command "casperjs test ..." : Sometimes, my shell displays all the test (its Ok!) Sometimes (screenshot #1), all tests is not done Sometimes (screenshot #2), I get a fail "check title" test, the previous open(url) didn't load the new url (?!) The screenshot of my shell: My code: casper.options.loadImages = false; var lines = [ "http:/

PhantomJS WebPage memory consumption?

北战南征 提交于 2019-12-06 07:45:37
Is there a programmatic (since i want to do it automatically at runtime) way to see how much memory a webpage uses when running it through PhantomJs? I am also using casperjs if that could be helpful. I have searched a lot but haven't found any way. PhantomJs uses QtWebKit so I don't have access to window.performance.memory. I want to have this information since I am setting up automated performance tests for a web application. Thanks in advance No, at this time this feature is not supported, but I have found issue about that https://github.com/ariya/phantomjs/issues/10031 来源: https:/

'Can't find module fs' when running casperjs on js file

对着背影说爱祢 提交于 2019-12-06 07:31:09
I am trying to run CasperJS on a javascript file that I have, and when I run > casperjs index.js it says 'CasperError: Cant find module fs'. The first line of index.js is var fs = require('fs'); I have node, casperjs, and phantomjs installed, why can't it find fs? If I am correct, fs is Node's file system? UPDATE: I added nodejs to my $PATH, but still no luck. Did you install the PhantomJS/CasperJS modules as well as the node fs module in your project? They don't seem to mix very well. I ran into an issue where installed all of these modules and I was getting the same error message you