casperjs

How do I run casper from within the phantomjs shell?

痴心易碎 提交于 2019-11-29 23:54:32
问题 Anyone know if and how it's possible to run casperjs from within the phantomjs shell (a.k.a InteractiveModeREPL )? I've also tried passing the direct path to the casper.js module and that has not worked either. Progress/Update: Tried phantomjs.injectJs('C:/casperjs/module/casper.js'); but got Error: Cannot find module 'colorizer' I guess I'm getting close. This gets me closer but still missing path: phantomjs.injectJs('C:/casperjs/module/bin/bootstrap.js') errors out with Cannot find package

Is there a way to step in to CasperJS code and Debug step by step [closed]

£可爱£侵袭症+ 提交于 2019-11-29 22:29:34
Though I have been using CasperJS for some time, and rely on console logging for debugging. I was wondering if there is any IDE which support CasperJS step by step debugging or there is other way(remote debugging) to step in to CasperJS code? Has anybody successfully done it? Any information will be helpful. Thanks, Fanch When I want to debug with CasperJS, I do the following : I launch my script with slimerJS (it opens a firefox window so I can easilly see click problem, problems of form filling-ajax return error, media uploading...-, and in which step the code blocks). With that I don't

Taking reliable screenshots of websites? Phantomjs and Casperjs both return empty screen shots on some websites

末鹿安然 提交于 2019-11-29 21:00:43
Open a web page and take a screenshot. Using ONLY phantomjs: (this is a simple script, in fact it is the example script used in their docs. http://phantomjs.org/screen-capture.html var page = require('webpage').create(); page.open('http://github.com/', function() { page.render('github.png'); phantom.exit(); }); Problem is that for some websites (like github) funny enough are somehow detecting and not serving phantomjs and nothing is being rendered. Result is github.png is a blank white png file. Replace github with say: "google.com" and you get a nice (proper) screenshot as is intended. At

How to properly hover the mouse over an element in PhantomJS/CasperJS

瘦欲@ 提交于 2019-11-29 18:10:12
In my opinion, a problem of getting dynamic content is really very ambiguous. I tried to find some useful information, used many different code examples, certainly modifying them to my purposes, but unfortunately, without any results( I need to get some contents from here . Try to explain detailed what are the problems i faced to (need to notice, that all i do is exclusively for my own use!). Main web site page has main navigation ( Main nav pic ) list with each list class "menu__category-trigger". Every "menu__category-trigger" has each own dropdown menu container. All these dropdown menu

How to change PhantomJS version

亡梦爱人 提交于 2019-11-29 18:07:26
I am learning PhantomJS for scraping. I started to incorporate CasperJS. When I run CasperJS and the filename I get back CasperJS needs PhantomJS v1.x How do you change the PhantomJS version to use CasperJS? Is there an easier way to scrape a website that is heavy javascript? I used cheerio and require but they only get static html. This message is shown if you try to use PhantomJS 2.x with a CasperJS version <= 1.1-beta. use different PhantomJS once If you also have PhantomJS 1.x on your system, you can simply change the executable like this in the command prompt. cmd.exe: C:\path> set

Select value from dropdown list using the text

本秂侑毒 提交于 2019-11-29 17:25:16
How do you select a value from a dropdown list, by using the text, instead of the value or the index? The HTML: <select name="category_group" id="category_group" sel_id="" > <option value="0" selected="selected">Kies de rubriek</option> <option value='1000' style='background-color:#dcdcc3;font-weight:bold;' disabled="disabled" id='cat1000' > -- VOERTUIGEN -- </option> <option value='1020' id='cat1020' > Auto's </option> <option value='1080' id='cat1080' > Auto's: Onderdelen </option> <option value='1040' id='cat1040' > Motoren </option> <option value='1140' id='cat1140' > Motoren: Onderdelen <

Casperjs scraping dynamic content

给你一囗甜甜゛ 提交于 2019-11-29 17:13:50
I'm trying to scrape this page using Casperjs. The main function to my code works just fine, but the content is loaded dynamically and I can't figure out how to trigger that. This is what I'm doing right now: casper.waitFor(function() { this.scrollToBottom(); var count = this.evaluate(function() { var match = document.querySelectorAll('.loading-msg'); return match.length; }); if (count <= 1) { return true; } else { return false }; }, function() { // do stuff }); The wait timeout just expires, even though I've increased it to 20s, and the new content never gets loaded. I've tried adapting this

How to fill a select element which is not embedded in a form with CasperJS?

拟墨画扇 提交于 2019-11-29 16:33:38
My html code is: <div class="setting-control"> <select class="on-off" id="custom-cache-pref"> <option value="">Default</option> <option value="byc">Bypass cache</option> <option value="basic">Basic caching</option> <option value="iqs">Ignore query string</option> <option value="agg">Aggressive caching</option> <option value="all">Cache everything</option> </select> </div> Usually with casperjs I would use this.fillSelectors('form[name="formName"]', { 'select[id="custom-cache-pref"]': 'byc' }, false); to select option "byc" but this time the "select" element is not embedded in a form! How can I

CasperJS script never exits

随声附和 提交于 2019-11-29 15:24:06
My CasperJS script never stops executing. var casper = require('casper').create(); casper.userAgent('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'); casper.start('https://www.google.co.in/',function(){ casper.wait(3000,function(){ this.echo(this.getTitle()); }); }); casper.run(); It only looks as if CasperJS never exits. This is only an issue on windows. You probably see something like this: C:\> casperjs script.js C:\> Some script output More script output _ It has something to do with how CasperJS is installed and invoked. This

Running 'casperjs test' in phantom

扶醉桌前 提交于 2019-11-29 12:09:09
So I have a file running in node which runs a local copy of PhantomJS as below shows: phantom.casperPath = 'node_modules/casperjs'; phantom.injectJs('node_modules/casperjs/bin/bootstrap.js'); var casper = require('casper').create({ viewportSize: config.viewportSize }); casper.test.begin('Runing tests here', 5, function suite(test) { // Tests here }); Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following error in my console: CasperError: casper.test property is only available using the `casperjs test`