casperjs

Can't run the testing framework in CasperJS

半城伤御伤魂 提交于 2019-12-08 10:56:21
问题 I am learning CasperJS and how to write unit tests but my test fails. I tried the example code from the website and it fails as well! I am confused about how to use the testing framework in CasperJS. This is my code: var casper = require('casper').create(); casper.test.begin('The title exists', 1, function suite(test) { casper.start('http://stackoverflow.com', function() { test.assertExists('title'); }).run(function() { test.done(); }); }); and execute it: casperjs test script.js Output: Test

Unable to download .zip file from url with casperjs

无人久伴 提交于 2019-12-08 06:41:07
问题 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

Why can't CasperJS show part of a web site 'outlook.com'?

我与影子孤独终老i 提交于 2019-12-08 06:17:38
问题 I have problem of capturing everything of a web page. After I log in to outlook.com using regular browser, it should show the inbox message in the right side: However, when I use CasperJS, it is just blank. Does anyone have any idea? I have include a temporary login id in the script, you can test it if you can, thanks. Here is the script: var casper = require('casper').create({ verbose: true, logLevel: "info", viewportSize: {width: 1280,height: 720}, pageSettings: {userAgent: "Mozilla/5.0

Testing React Apps with Phantom/Casper

只愿长相守 提交于 2019-12-08 04:42:47
问题 I'm diving into functional testing and attempting to get a few simple tasks working. The app is built in ReactJS and I've decided to use Phantom/Casper. The problem is that even the most basic tasks fail. In short, is there a trick for testing React apps with Phantom/Casper? I've installed Phantom (v.2.1.1) and Casper (v1.1.0-beta5). As a first attempt I created a simple script to capture an image: capture.js var casper = require('casper').create({ viewportSize: { width: 1024, height: 768 },

Casperjs test if page opens

為{幸葍}努か 提交于 2019-12-08 04:30:42
问题 It can be done with pure phantomjs like this: var page = require('webpage').create(); var address = 'http://google.com/'; page.open(address, function(status) { if (status !== 'success') { console.log('FAIL to load the address'); } else { console.log('SUCCESS'); } phantom.exit(); }); but I'd like it to support casperjs test command. The best I came up with is: casper.test.begin("Hello, Test!", 1, function(test) { var page = require('webpage').create(); var address = 'http://google_doesnotexist

Installing casperJS and phantomJS in WIndows Apache 2.4 to pass data to PHP

馋奶兔 提交于 2019-12-08 03:06:35
问题 I am attempting to run my casperjs script by clicking a Run button in a website. My local set up is PHP 5.5.14 with Apache 2.4 on Windows7 [properly running; tested with php page]; and my question is: how do I properly install casperJS and phantomJS so that its PATH is recognized when I execute the script. I need to know what the path is in Windows to be able to use this: putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); . I have gone over the following possible solutions but none of

Ways to reduce CPU usage while using PhantomJS/CasperJS

蓝咒 提交于 2019-12-08 02:14:54
问题 Am using PhantomJS and CasperJS for screenscraping and stuff. The issue which I am facing is that its taking too much CPU usage which makes me feel it might not be that scalable. Are there any ways to reduce CPU usage for the same. Some of which I can think of are: 1) Disable image loading 2) Disable js loading Also I want to know if python is more light(in terms of CPU usage) than phantom for the scraping purpose. 回答1: After 5 and a half years I don't think you are having this issue anymore,

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

柔情痞子 提交于 2019-12-07 23:19:04
问题 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. 回答1: 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

PhantomJS WebPage memory consumption?

百般思念 提交于 2019-12-07 21:45:13
问题 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 回答1: No, at this time this feature is not

CasperJS screenshot is only a small part of page

扶醉桌前 提交于 2019-12-07 11:19:33
问题 The CasperJS documentation for captureSelector() does not say anything about how to set the size of the screenshot. The default (at least on my system using webkit, Windows 8) seems to be to take a tiny screenshot of the top left portion of the page. Am I looking in the wrong place? I found viewportSize. I assume this is what I need, but does anyone have code that can set this to a sensible default (like 100%)? FYI this.viewport('100%', '100%'); just hangs, so I assume it doesn't take % . Do