Installing CasperJS on Windows: How to do it correctly? - windows

I know there is a documentation from CasperJS website about how to install CasperJS on Windows, but bear with me these guys only explained for the pros only.
If you are new to all this CasperJS and PhantomJS world, you dont stand a chance to understand not even spending two days trying to search the net for a better explanation.
I am working on a project that requires a screenshot of each website listed on my project website, looking around i found out that PhantomJS would be great for this task (website screenshot).
I downloaded PhantomJS and and pasted its phantomjs.exe file in system32 which is working well when i use cmd.exe to send command.
I even managed to grab screenshot with the phantomjs.exe only. but my problem came when i noticed the the workload could be easier when these two work together (CasperJS and PhantomJS) as i can even be able to reduce the size of the screenshot when using CasperJS.
In fact the only use that i want CasperJS for is the limiting of the shot size but since yesterday i have been trying to figure out how to make CasperJS work on Windows but with no avail.
I have downloaded CasperJS and tried to install it in many ways also trying to follow the documentation but nothing.
I changed the CasperJS folder name from its download name to CasperJS as the documantation suggest but when i check in the cmd trying to call some commands, nothing happens.
Anyway to cut the story shot can anyone help me in simple terms considering that i am a newbie to explain how CasperJS can be installed on window or if possible with PhantomJS only how can i re-size the iamge the the program produces lets say if i want a 960 to 400px.

Poor documentation for windows. http://casperjs.org/installation.html#windows
It starts off assuming you have already installed without telling you how to install.
So here it is if anyone else is confused about this. There is no actual install. It's just extracting zip contents to the right place.
download phantomjs for windows from the phantomjs site (it's a zip with binary inside)
extract the contents to C:\phantomjs
download the casperjs zip file from the casperjs website
extract the contents to C:\casperjs
Now you can add the following to the end your system or user PATH variable
;C:\phantomjs;C:\casperjs\batchbin
restart cmd.exe to pick up the new path variable or logout/login if you are running Console2 or Conemu terminal emulator (they won't pick up new paths by a simple close and re-open)
Now in the docs it says to run it like this
casperjs.bat myscript.js
Actually since both phantomjs.exe and casperjs.bat are now in the system PATH you can leave off the extension like this.
casperjs myscript.js
And when running phantomjs.exe just run
phantomjs
One more thing. It really doesn't matter where you install as long as you add that path to the system PATH. I installed to C:\usr\phantomjs and C:\usr\casperjs.

I itemize below the method that has served my needs on both my personal Windows and Ubuntu work PC. DO note that my method doesn't fiddle with PATH settings but involves a command you could save somewhere & copy and paste as needed:
Step 1: Gather the prerequisites
Download the casperjs and phantomjs versions you want to use
Make a directory to contain the things I want to list
Extract the downloaded phantomjs & copy its executable into the directory of step b
Extract casperjs and rename its folder to casperjs
Copy the renamed casperjs folder to the directory of step b
Create and save a file config.json to the directory of step b
config.json should contain phantomjs configurations as found here: http://phantomjs.org/api/command-line.html
Step 2: Running your script
Whenever you want to work with a file, follow the Step 1 details above
The next step assumes that you are in the directory created in step
b of Step 1 also have a file named first.js
On Windows: phantomjs.exe --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli first.js
On Ubuntu: ./phantomjs --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli first.js
Experimental config.js and first.js are listed below:
config.json
{"sslProtocol": "any", "cookiesFile": "biscuit", "maxDiskCacheSize": 1000, "diskCache": true}
first.js
var casper = require('casper').create({
pageSettings: {
loadImages: false,
loadPlugins: true,
userAgent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'
}
});
var url = "http://casperjs.org/";
casper.start(url).wait(60 * 1000 * 1, function() {
casper.echo('1 min has passed');
casper.capture('casperjs.png');
casper.exit();
});
casper.run();
Addendum: download and save the details of screenshots.js and run it as
phantomjs.exe --config=config.json casperjs/bin/bootstrap.js --casper-path=casperjs --cli screenshots.js http://phantomjs.org
Run Tests: download & save the details of picturefill-test.js and run it as
phantomjs.exe --config=config.json casperjs/bin/bootstrap.js
--casper-path=casperjs test --cli picturefill-test.js

As of CasperJS 1.1.0-DEV Beta 3 you should use this PATH: C:\casperjs\batchbin even though the documentation found here states you need to use C:\casperjs\bin
The reason to this is because C:\casperjs\batchbin includes a .BAT which C:\casperjs\bin does not include anything except some.js files.

after a 3days work, i managed to get it work the problem was with the path and the installation of phantom. i had made the path to a folder but the installation was pointing to the exe file all i had to do was to put the exe file into a folder phantomjs and that was it thank for your help all.

Many of the other answers are out of date. Since it seems like the correct install process keeps changing all the time, I suspect my answer will be out of date also in a few days, but as of March 19, 2015, this is the answer. The other answers, even highly upvoted ones, do not work, so don't waste your time. Good luck. Casperjs seems quite good.
If you download PhantomJS 2.0 and casperjs 1.1-beta3 zip file and put the batchbin directory in the path and put phantom exe in that same folder, then run casperjs, on Windows 8.1 I get the error "CasperJS needs PhantomJS v1.x".
So, I got the latest casperjs direct from github, which has no batchbin directory, so I put just the C:\casperjs\bin directory in the path instead and this worked (sort of, I mean it seems to work well enough for me - although running casperjs c:\casperjs\tests\selftest.js seems to have a number of failing tests).
So to recap, the bad news is only the very latest bleeding edge casperjs works. The good news is the install is 1,2,3 simple:
Clone latest casperjs from github into c:\casperjs.
Copy phantomjs.exe (ver 2.0) to c:\casperjs\bin
Add c:\casperjs\bin to your windows path

Just in case you're using a notebook with dual graphic cards like I do: choose one of them to prevent issues. This article helped me out:
casperJS not finishing on windows
the casperJS documentation is pretty clear about it but I had no clue what to do until I read the notice above.

Fast forward to 2015... 5-steps win7 howto:
choco: PS me> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
git: choco install git -y
phantomjs 2.0: choco install phantomjs -y
casperjs source: git clone https://github.com/n1k0/casperjs -b phantomjs-2
Add the location of casperjs/bin to PATH
Done. You can now casperjs --version and live happily ever after.

Ok guys. So I think this thread needs refreshing for 2018!
So with npm, the effort is reduced significantly. Given that you have npm installed, open terminal and go to your project:
cd your_project_name
Now install casperjs. Use --save-dev, --save, -g or none as needed:
npm install --save-dev casperjs
Now install phantomjs. To do this, you should install phantomjs-prebuilt, because PhantomJS team changed their package name:
npm install --save-dev phantomjs-prebuilt
Run your spec:
casperjs your_spec_name.js

Related

Cannot run git clone or pip install commands

So i'm pretty new to the whole windows repo cloning thing. I installed python 2.7, added the path to my windows cmd and I still cannot run any git clone commands. It shows the following output :
git clone
File "", line 1
git clone
^
I've been scouring the internet for an answer but apparently it should work if I use cmd.
Any help would be appreciated!
git clone
File "", line 1
git clone
^
I have had the same issue recently with 3.7, so I made a new username and it worked. Kind of nice, a clean new Windows profile, even though I just started using it again compared to linux. A pain though.
Make sure all other versions of Python are not installed, or at least affecting the path to the file you need the pip installs to be saved. Python can be saved in a few different locations, and some rare times it has been shown in very obscure places. Check where your file saved on your PC. Probablu C:/ then could be many paths. /Users/UnserNameHere/Windows/ProgramFiles. I would use the search bar in the good old GUI while searching under the C drive (if you have multiple HDD/SDD then pic the one used for the C drive, if nothing comes up try the other drives.
Your looking for a file PythonFoundation I can't remember the entire name, however it will have a very long name Python Foundation are in the name of the file. This is where thing are store and where the path should be sending modules, at least the correct file inside that file.
Also try doing it from other Python versions installed. If you had 3.6 and got 3.7 it doesn't mean 3.6 has been deleted. Also doesn't mean you path, is not set to 3.6 while using 3.7. Same with Python 2, most people or many have both. The pip commands vary between python versions pip3 I believe is used (getting windows and linux a little mixed up right now)
If all fails do it the old fashon way, find the mod, download it, and move it to the python file I mentioned above. The homepage for python should have a tab linking to a page, or it's on the main page, letting you know where it has been known to save. Google how to see he path Pip is taking, or how to see if pip is installed and where, and what paths are set to.

Has anyone managed to add custom icons into Ionic in Windows?

I refer the instructions here
What I did (on Windows):
Install fontforge through web instead of 'brew'
Install SASS through Ruby GEM
Place my-icon.svg inside src/ (of the ionicons-master)
Run the python ./builder/generate.py
I think I am very closed. Until i saw this error message:
windowsError: The system cannot find the file specified
And I think I get even closer when I saw the last post of this link
But, I don't get what it means. I downloaded the .exe but it doesn't work.
Is it the python build only meant for MAC? Has anyone managed to make this work in Windows?

Why won't APKTool execute?

I was using APKTool and have been doing a lot of trials, using all the versions of APKTool. However, upon to my dismay, it won't work. Whenever I use it it will just be:
-bash: ./apktool: No such file or directory
I don't know what to do, as I tried using "./" as what websites are telling me, but still it just gives me this.
What should I do to fix this error. Thanks :)
-----Edit (December 23, 2015)-------
I have found the solution to the problem and it was just a redownload of APKTool itself. It also helped when I gained an understanding of Terminal and the Command Line Tools. I advice you to do the same thing too.
Perhaps you should reinstall apktool. You can find how to do it here:
http://ibotpeaches.github.io/Apktool/install/
Using "./" means that you want to run file located in current folder. Since you mentioned "bash" your apktool should be probably installed in "/usr/local/bin" so when you complete the installation do not add "./" just type "apktool" to run it.
If you want to check where apktool is installed run "which apktool"
or simply use the apktool online: http://www.javadecompilers.com/apktool
No installation - no hassle!

Full installation instruction of youtube-dl in windows

I have just downloaded the youtube-dl-2014.07.15.tar_2.gz in my windows. At first I want to tell I don't know anything about python. And I already have installed python 2.7. Can anyone give me instruction to execute these scripts?
I have already tried to run...but there is some error like these. "No mudule named youtube-dl"
I want a fresh start. Now I am using windows 8.1 and I have also tried youtube-dl.exe. And there is also problem like screenshot
If I want to get worked both script and program what will I do?Any helps will be appreciated. If you give me instruction from scratch that will be better.
To install youtube_dl in Python on Windows (command from their github):
Tested with Python 3.9 on Windows 10
pip install --upgrade youtube-dl
Now when using it, notice that the name of the Python module is with an underscore.
Because it is a Python module, use it like so:
py -m youtube_dl <video url>
Of course video url is the video you want to download
This seems to be caused by a limitation of py2exe. You may want to file a youtube-dl bug report for moving to a cxfreeze, which should not have that problem. In any case, simply moving the youtube-dl.exe file into another directory such as C:\Users\Shamim should fix the problem.
you need just to put the youtube-dl.exe file in in your home directory or any other location on your PATH.
You can see your PATH in your "Envirenment Variables"

Installing Zend Framework 2 on XAMPP in Windows

I know this question may have appeared few times here and in the internet. But still I feel it is not clear for somebody who wanted to enter into the world of frameworks. I have followed these links Rob Allens Tutorial, ZF Quick Tutorial.
But some how I feel it is not quite clear with the installation part. I have a windows system basically Vista with the newest version of XAMPP installed. I have downloaded the latest version of ZFSkeletonApplication from this link ZFSkeletonApp, extracted the skeleton contents, renamed the folder to zendframework and moved it to xampp folder i.e now ZF skeleton is in c:\xampp\zendframework.
So until here everything seems clear and easy, from here I am some how lost with the configurations. Can some one elaborate the things from here how to install the Zf and make it work, like changes in the include paths, .htaccess files and so on. Please do remember that I have windows with XAMPP on it. If some one can guide me exactly for this set up, it would be helpful.
P.S. It would be good if one can provide info about the changes which I need to make with examples consisting of paths, so that I am not lost, for example like you can find .htaccess file here(ex pathname), changes in .htaccess file should be so and so.
Thanks
For future references, i also made a big post on how to install ZF2 on a windows xampp environment right here Install ZF2 on Windows Xampp
OK, i have done this on multiple systems now. For a home system the following steps work quite well:
Download msysGit and install it to any directory
Run the git-cmd.bat from the msysGit-Folder
Move into the directory you want i.e. C:\xampp\htdocs\ (this is done via cd dirname or cd .. to go up a level, change partition with D: and hit enter)
Run the following command. The <OptionalFolderName> would be the name of a Sub-Directory of htdocs, if you skip this, the folder will get named ZendSkeletonApplication
git clone git://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>
Possible Trouble Scenario (fatal:unable to connect to github.com)
Once again at workplaces, pretty often the default port (9418) for the git-protocol is blocked. If this is the case for you, then you should try one of the following Commands
git clone https://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>
git clone git#github.com:zendframework/ZendSkeletonApplication.git <OptionalFolderName>
Now you are not done yet. The skeleton Application is installed, but the framework is still missing, here some people might run into the first problems, but this actually is quite easy.
We're still at the command line interface
cd <OptionalFolderName> or cd ZendSkeletonApplication depending on what you did earlier
php composer.phar self-update
php composer.phar install (this might take a while)
So, this is the part where lots of things can happen. I have two scenarios happened to me:
Scenario #1 No directory write permissions
This is easily handled by running the command line interface with administrator privileges
Scenario #2 Working behind a router (i.e. at work)
Personally i didn't have to do much to get this working, but the line might change depending on your proxy. Personally i did the following at the command line interface
SET HTTP_PROXY=http://proxy.domain.tld:8080 you might also be good with
SET HTTP_PROXY=proxy.domain.tld:8080 don't ask me why, but i needed the http://
With all those done, you should have an almost running ZendSkeletonApplication. The other part is how to set up your virtual host, but i won't go into detail on this, as that's even ZF1 Stuff and everyone should be familiar with that by now, if not, there's good resources to learn out there.
I hope i could be of help to you.
Setbacks have to install in Windows, but I ended up finding a solution. From ZF2 to install on windows via git, for this is the only use that simulates msysGit git linux on windows, for it is only access the tutorial: http://zf2.com.br/tutoriais/post/instalando-o-git-no-windows-para-fazer-a-instalacao-do-zf2-somente-no-comando-do-windows-via-composer
Since I had lot dependency extension problems (mostly .dll files) with old version of XAMPP, so first thing I did was made sure I uninstall all previous versions of PHP already present on my system as well as old XAMPP. Then installed latest XAMPP v3.2.2 (using latest XAMPP 3.2.2-32-bit on Win-7-64-bit). Then followed installation steps in XAMPP Documentation under title Start a New Zend Framework 2 Project.
I had issues while installing composer also with old-XAMPP, but somehow those errors didn't appear during composer installation this time. And, I successfully installed ZEND till I typed http://localhost:8081/myapp/ (I renamed my ZendSkeletonAppliction folder as myapp as per documentation) into my browser to access the same and met the error which said:
Fatal error: Uncaught RuntimeException: Unable to load ZF2. Run php composer.phar install or define a ZF2_PATH environment variable. in C:\xampp\apps\myapp\htdocs\init_autoloader.php:51
Stack trace:
#0 C:\xampp\apps\myapp\htdocs\public\index.php(18): require()
#1 {main} thrown in C:\xampp\apps\myapp\htdocs\init_autoloader.php on line 51
Composer.phar was not even present the first time I downloaded ZendSkeletonApplication‐master.zip from Github (there was only composer.json and composer.lock files present). Anyhow I didn't need them since I followed XAMPP Doc which doesn't call composer.phar in command line:
composer create‐project ‐s dev zendframework/skeleton‐application path/to/install
I am not that tech-savvy to know how to 'define a ZF2_PATH environment variable' correctly, so I wasted time looking for solution online, couldn't find any (which is when I stumbled on this forum which also turned out not to have a solution for my query). In the end, in a fit of depression and anxiety, serendipity happened. All I did was as per XAMPP's ZEND documentation I right-clicked inside C:\xampp\apps\myapp\htdocs folder and clicked 'Composer Install' which reinstalled the Zend files from cache. Then refreshed http://localhost:8081/myapp/ and the Zend intro page appeared.
I just did it like that:
D:\web_dev\zendapp>C:\PHP\php.exe composer.phar self-update
it worked perfectly

Resources