Example Scripts for PhantomJS
PhantomJS comes with a lot of included examples.
Basic examples
- arguments.js shows the arguments passed to the script
- countdown.js prints a 10 second countdown
- echoToFile.js writes the command line arguments to a file
- fibo.js lists the first few numbers in the Fibonacci sequence
- hello.js displays the famous message
- module.js and
universe.js
demonstrate the use of module system
- outputEncoding.js displays a string in various encodings
- printenv.js displays the system’s environment variables
- scandir.js lists all files in a directory and its subdirectories
- sleepsort.js sorts integers and delays display depending on their values
- version.js prints out PhantomJS version number
- page_events.js prints out page events firing: useful to better grasp
page.on*
callbacks
Rendering/rasterization
Page automation
Network
Testing
Browser