casperjs

How use --config with CasperJS

江枫思渺然 提交于 2019-12-06 06:29:40
I've read the Casper documentation and they say that ALL PhantonJS cli options is available on CasperJS but I am trying to use --config=/path/to/config.json and is not working. Is there a way to fix this or do something similar since I don't want to be editing the configs on terminal. casperjs --config=config.json test.js My config.json file: { "load-images" : false } My test.js file: var casper = require('casper').create(); casper.start('http://www.example.com/', function(){ this.capture('image.png'); }) .run(); That code above is loading the images. Of course this is a simple example and

Running a casper.js script from cron

流过昼夜 提交于 2019-12-06 04:52:00
问题 I'm trying to run a casper.js script via cron. Everything works fine when I run the script manually, but when I run it via cron I get the following errors: Traceback (most recent call last): File "/usr/local/bin/casperjs", line 46, in <module> status = subprocess.call(CASPER_COMMAND) File "/usr/lib/python2.6/subprocess.py", line 480, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.6/subprocess.py", line 633, in __init__ errread, errwrite) File "/usr/lib/python2.6

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

孤街醉人 提交于 2019-12-06 04:41:53
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 them mention on how to properly install casperJS and phantomJS for the web server to recognize them:

casperjs: evaluating document.querySelector returns a null

女生的网名这么多〃 提交于 2019-12-06 02:36:44
问题 I'm using the waitForSelector() and captureSelector() methods in CasperJS to wait for and select an element using a CSS selector, then save a screenshot of it. However, I'm finding that because the css background has been set to transparent , the screenshot turns out pretty ugly, so I'd like to set the background to white . I've made sure that I'm using document.querySelector in an evaluate() call, but that doesn't seem to work. Here's my script (you can ignore everything before casper.start(

How to perfectly isolate and clear environments between each test?

核能气质少年 提交于 2019-12-06 02:29:57
问题 I'm trying to connect to SoundCloud using CasperJS. What is interesting is once you signed in and rerun the login feature later, the previous login is still active. Before going any further, here is the code: casper.thenOpen('https://soundcloud.com/', function() { casper.click('.header__login'); popup = /soundcloud\.com\/connect/; casper.waitForPopup(popup, function() { casper.withPopup(popup, function() { selectors = { '#username': username, '#password': password }; casper.fillSelectors(

testing DOM elements with phantomjs/casperjs

為{幸葍}努か 提交于 2019-12-06 00:04:22
I've got an AJAX-based javascript application which I would like to cover with interface tests. For example, I would like to write a test that loads my website (from a given URL) and checks if there are some DOM elements (given ids and given classes) that exist. The problem is that when I enter the URL in a browser, my application has a Loading... label displayed and an AJAX request is sent beneath. When AJAX response arrives, some processing is done and the right webpage content is displayed ( Loading... label is hidden). So far I've got this code: casper.test.begin('Main page test', 2,

How to pass data from the “then” methods in CasperJS?

﹥>﹥吖頭↗ 提交于 2019-12-05 23:37:33
问题 It's common to have multiple then methods when working with CasperJS. The following is an example: casper.then(function(){ var a = "test"; // ... }) casper.then(function(){ // how to use the variable a in the first "then" }) My question is, what's the common way to pass values from former then s to following then s? For the aforementioned example, how to use a in the second then ? 回答1: There are many way, but the easiest would be to use global variables. If you don't want to clutter your

How can I make casperjs repeat a loop until a certain condition is met?

北城以北 提交于 2019-12-05 21:55:41
I'm trying to get casperjs working with the following situation: A web page loads, then within that page, it ajax loads data items along with a 'read more' button which in turn loads some more data items. I need the script to recursively check if the 'read more' button exists (as there are many data items to load), if so, click it, else continue with the rest of the script and output the full page as a jpeg. I've tried by writing the code below, but it doesn't loop as I had hoped. It just clicks the button once, then outputs the image, even though more data loads, and the button still exists

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

你说的曾经没有我的故事 提交于 2019-12-05 18:37:48
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 found', 'ERROR'); phantom.exit(); } this.capture('img/'+user_email+'_login.png'); }); casper.run(); please

CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any

巧了我就是萌 提交于 2019-12-05 16:08:51
I've had issues with CasperJS and SSL, but using --ssl-protocol=any has always fixed the problem, as referenced in this answer. In this case, I'm still having issues. I put this in the command line: casperjs --ssl-protocol=any --ignore-ssl-errors=true sanity.js This is sanity.js: var casper = require('casper').create({ verbose: true, logLevel: 'debug' }); casper.on("resource.error", function(resourceError){ console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')'); console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError