PacktLib: Getting Started with PhantomJS

Getting Started with PhantomJS

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Getting Started

Downloading PhantomJS

Building PhantomJS from source

Working with PhantomJS

PhantomJS JavaScript API

The phantom object

The command-line arguments

Writing PhantomJS scripts

Summary

Manipulating Page Content

Opening a web page

Playing with DOM elements

Simulating mouse clicks

Working with form fields

Summary

Handling Events and Callbacks

Listening to page events

Capturing alert messages

Answering prompt messages

Responding to confirm pop ups - OK or Cancel

Performing user events

Summary

Capturing Errors

Handling PhantomJS errors

Capturing page script errors

Anticipating the page loading error

Exiting with error codes

Summary

Grabbing Pages

Undocumented supported image format

Screenshot dimensions

Saving web pages as PDFs

Summary

Accessing Location-based Services

Checking a location based on IP address

Getting driving directions

Looking up for pizza delivery establishments

Summary

Working with Files

PhantomJS FileSystem API

Reading files

Writing files

Character encoding

Summary

Cookies

Reading cookies

Baking some cookies

Deleting cookies

Keeping cookies

Summary

External JavaScript

Modules

Using the object-oriented modules

Using third-party JavaScript libraries

Summary

Testing with PhantomJS

What is unit testing?

Unit testing with Jasmine

Summary

Maximizing PhantomJS

CasperJS

GhostDriver

Screenshots, web metrics, and more

Summary

Index