casperjs

CasperJS File Download Times Out After 30 Seconds

与世无争的帅哥 提交于 2019-11-30 14:47:38
I'm using CasperJS to download a 15 MB file. In the browser, the download takes about 3 minutes to complete. With Casper, the .download function for the same url returns after exactly 30 seconds, and the file written to disk is 0 bytes. I've tried setting longer timeouts like this: var casper = require("casper").create({ pageSettings: { webSecurityEnabled: false }, waitTimeout: 500000, stepTimeout: 500000 }); But they have no effect. Here's my download function: casper.on('resource.received', function (resource) { var url, file; if ((resource.url.indexOf("myDownloadUniqueString=") !== -1) ) {

Cannot find module 'casper' when invoking through PhantomJS

老子叫甜甜 提交于 2019-11-30 13:57:36
I installed PhantomJS in C:\xampp\htdocs\phantom and also I installed CasperJS in this folder C:\xampp\htdocs\casper When I tried to run these sample code on casper site using phantomjs test.js command: var casper=require('casper').create(); casper.start('http://google.fr/'); casper.thenEvaluate(function(term) { document.querySelector('input[name="q"]').setAttribute('value', term); document.querySelector('form[name="f"]').submit(); }, 'CasperJS'); casper.then(function() { // Click on 1st result link this.click('h3.r a'); }); casper.then(function() { console.log('clicked ok, new location is ' +

Output client-side console with casper/phantomjs

我与影子孤独终老i 提交于 2019-11-30 11:04:49
Going through the casperjs documentation I couldn't find where I could see the console.log from client-side javascript. Is this possible? I'm not really sure to fully understand your question, but you can do something like the following: var casper = require('casper').create({ logLevel: "debug" }); casper.on('remote.message', function(message) { this.echo(message); }); casper.start('http://google.com/', function() { this.evaluate(function sendLog(log) { // you can access the log from page DOM console.log('from the browser, I can tell you there are ' + log.length + ' entries in the log'); },

php execution phantom js works but casperjs does not work permission denied

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 07:42:54
问题 okay so i am running centos 6.5 with zpanel setup. this then has phantom js and casperjs both setup and working it the /usr/local/bin directory. i use this php command for phantomjs and casperjs echo exec('/usr/local/bin/casperjs --version 2>&1'); phantomjs works fine but casperjs gives me this error sh: /usr/local/bin/casperjs: Permission denied can anyone out there help me fix this problem it is just a pain output for ls -al casperjs [root@cyber-hosted ~]# ls -al casperjs total 100 drwxr-xr

Headless browser testing with download functionality?

余生颓废 提交于 2019-11-30 07:30:30
问题 I've been looking for a solution to do headless testing in osx. But I need the ability to save files returned by the server. I've tested selenium, phantomjs, casperjs and have looked into anything I could find online. none of them supports downloading. am I missing something? are there any headless browser/testing frameworks that support downloads? 回答1: What you can do is: start a virtual display (see Xvfb) start up Firefox browser with preferences configured to automatically save csv files

How to fill up form using CasperJS without form tag

▼魔方 西西 提交于 2019-11-30 03:50:16
问题 I'm new to CasperJS and I'm having problems in logging in into this site http://weibo.com/login.php here's what I've tried this.fill('form#contact-form', { 'username': 'test@test.com', 'password': 'anypassword', }, true); I can't used that since it has no form. so I tried a different method using sendKeys. this.sendKeys('.W_input ', 'tinkerbell@gmail.com'); Now my problem in here is that the input text has no ID in it, only a CLASS and both username and password have the same CLASS in it. how

How to tell CasperJS to loop through a series of pages

ε祈祈猫儿з 提交于 2019-11-30 03:48:21
I try to make CasperJS achieve the following: Go through a series of pages that are named sequentially by date. On each page, locate a PDF link. Download the PDF. I got some working code, but I don't understand how CasperJS is going through the sequence of events. For instance, in the code sample below, CasperJS tries to process step 2, and throws a "ReferenceError: Can't find variable: formDate", while step 1 isn't executed at all for some reason. What's wrong with my reasoning? It seems to me that the while loop is executed at a different speed than the casper.then methods. casper.start();

Can I get the original page source (vs current DOM) with phantomjs/casperjs?

China☆狼群 提交于 2019-11-30 03:35:30
问题 I am trying to get the original source for a particular web page. The page executes some scripts that modify the DOM as soon as it loads. I would like to get the source before any script or user changes any object in the document. With Chrome or Firefox (and probably most browsers) I can either look at the DOM (debug utility F12) or look at the original source (right-click, view source) . The latter is what I want to accomplish. Is it possible to do this with phantomjs/casperjs? Before

How can I maximize the browser window while running test scripts in casperjs using slimerjs

我怕爱的太早我们不能终老 提交于 2019-11-30 03:09:08
问题 I'm unable to view the full window while running test scripts in casperjs using slimerjs engine . could any one please help me to increase the mozila browser window size 回答1: Sure, use the phantom/slimer viewportSize option in casper : casper.options.viewportSize = {width: 1600, height: 950}; Or the casper function : casper.start(url) .viewport(1600,1000) .{...} With the function you can easily change the window size during steps of a scenario. And the scrollTo(), srollToBottom() functions

How to click a “select option” and then evaluate loaded content with casperjs

▼魔方 西西 提交于 2019-11-30 02:40:30
问题 I'm trying to crawl the sizes for this product: Link to product The problem: The sizes are loaded after the color of the product is selected. In the product page's source code, I can see that the dropdown has a onchange-method: It clicks the form #postColor onchange. The select dropdown: <select name="color" id="color" class="cposelect" onchange="document.getElementById('postColor').click();" style="width:150px;margin-right: 20px; float: left;"> <option selected="selected" onfocus="if (this