casperjs

CasperJS click() doesn't load new html

拥有回忆 提交于 2019-12-05 11:25:26
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.waitForSelector('div.talk-sharing__tools a.rate-button', function() { this.then(function() { this

What is the correct way to launch slimerjs in casperjs (with an absolute path)?

戏子无情 提交于 2019-12-05 10:19:19
Well, i can launch slimerjs by specifying the path of the slimer.bat file : C:\bin\slimerjs\slimerjs.bat and then execute my file. But if i modify casperjs file (in bin\ ) and modify the default exec for slimer : 'env_varname': 'SLIMERJS_EXECUTABLE', 'default_exec' : 'C:\bin\slimerjs\slimerjs.bat' when i execute the casper command : casperjs --engine=slimerjs test.js It doesn't work, the path to slimerjs.bat seems to be ignored. I tried this too : https://github.com/laurentj/slimerjs/blob/master/BUILD.md But the slimerjs.exe alone isn't sufficient, i need to have application.ini and omni.ja in

Wait for an element to have a specific text with CasperJS

情到浓时终转凉″ 提交于 2019-12-05 09:21:44
I'm using CasperJS to read a certain web page. What I want to do is load a web page in CasperJS. Then, wait for a certain HTML element to have a specific text. So what I'd LIKE to do is this: var casper = require('casper').create(); casper.start('http://www.example.com/somepage', function() { this.echo('Home page opened'); }); // wait for text based on a CSS selector casper.waitForText('.someCssClass', 'dolor sit', function() { this.echo('found title!'); }); // when text is eventually found, then continue with this casper.then(function() { ... } ); casper.run(); So I'd like to use waitForText

Issues getting CasperJS to upload image to file field - tried CasperJS fill() and PhantomJS uploadFile()

北慕城南 提交于 2019-12-05 07:56:43
I'm trying to use CasperJS to upload images to a web-form. My form looks something like this: <form action="" method="POST" enctype="multipart/form-data" class="form-vertical"> ... <legend>Campaign Banner</legend> <div class="control-group image-field "> <label class="control-label">Now Large</label> <div class="controls"> <div class="file-field"><input id="id_now_large_image" name="now_large_image" type="file"></div> <div class="image-preview"></div> <div class="clear"></div> <span class="help-inline"></span> </div> </div> <div class="control-group image-field "> <label class="control-label"

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

做~自己de王妃 提交于 2019-12-05 07:14:28
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 with require like that: var parsingStrategy = require(strategiesPath + strategyName); and the path to

How to break CasperJS' repeat function when a condition is fulfilled?

廉价感情. 提交于 2019-12-05 05:54:14
问题 I want to know if i can break a casper.repeat loop. I have this script which does this..: Searches google for agent 001, agent 002, agent 003, agent 004, agent 005, agent 006..... ....'til agent 011. I want it to stop looping after it finds the text "James Bond". Now it finds it, prints it out, but i dont know if and how to stop the casper.repeat loop. var casper = require("casper").create({ clientScript: ["jquery.min.js"], verbose: true, logLevel: "info" }); var mouse = require("mouse")

Setting paperSize for PDF printing in Casper

谁都会走 提交于 2019-12-05 02:49:35
In generating PDFs in Phantom, I can set the paper size like this: page.paperSize = { height: '8.5in', width: '11in', orientation: 'landscape', border: '0.4in' }; then the page.render(output) function generates a PDF properly. In other words, the size is correct and it has many pages of that size. I can't get this to work in Casper (and I'm not sure if it is supported). So for example, the following: var casper = require('casper').create({ paperSize: { height: '8.5in', width: '11in', orientation: 'landscape', border: '0.4in' }, logLevel: 'debug', verbose: true }); ....this.capture('print.pdf')

How to write own CasperJS modules?

我的未来我决定 提交于 2019-12-05 02:28:10
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! 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 by now" casper.thenOpen casper.cli.get("url") + "/myCoolPage", -> @test.assertExists '#myCoolDiv' casper.then

communication between Node/Express and Spooky/Casper js

◇◆丶佛笑我妖孽 提交于 2019-12-04 22:23:18
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 + '/..')); site.get("/", function(req, res) { fs.createReadStream("./index.html").pipe(res); }); site.get('

Using casperjs and PHP to save data

谁都会走 提交于 2019-12-04 21:22:58
I've been looking for some kind of tutorial or example on how to do this, but either I'm not understanding that the solution is right under my nose, or no one has really put this out there. What I'm trying to do is use casperjs to automate a process where I create an account on a website. I will be providing a few different user names, and then I want to output a file at the end with the username that was used for registration along with the password. If I don't need to use PHP to do this, that's fine as well. I'm just very confused. Thanks for the help. Not sure to fully understand your