Book Image

Getting Started with PhantomJS

By : Aries beltran
Book Image

Getting Started with PhantomJS

By: Aries beltran

Overview of this book

PhantomJS is a headless WebKit browser with JavaScript API that allows you to create new ways to automate web testing. PhantomJS is currently being used by a large number of users to help them integrate headless web testing into their development processes. It also gives you developers a new framework to create web-based applications, from simple web manipulation to performance measurement and monitoring.A step step-by by-step guide that will help you develop new tools for solving web and testing problems in an effective and quick way. The book will teach you how to use and maximize PhantomJS to develop new tools for web scrapping, web performance measurement and monitoring, and headless web testing. This book will help you understand PhantomJS’ scripting API capabilities and strengths.This book starts by looking at PhantomJS’ JavaScript API, features, and basic execution of scripts. Throughout the book, you will learn details to help you write scripts to manipulate web documents and fully create a web scrapping tool.Through its practical approach, this book strives to teach you by example, where each chapter focuses on the common and practical usage of PhantomJS, and how to extract meaningful information from the web and other services.By the end of the book, you will have acquired the skills to enable you to use PhantomJS for web testing, as well as learning the basics of Jasmine, and how it can be used with PhantomJS.
Table of Contents (13 chapters)
12
Index

What this book covers

Chapter 1, Getting Started, starts by introducing what PhantomJS is, how to get and install it, and then goes directly into creating your very first script.

Chapter 2, Manipulating Page Content, shows you how to directly interact with pages that we open in our headless browser.

Chapter 3, Handling Events and Callbacks, explores how to capture events that web pages generate for the browser and reacts accordingly. We will also simulate browser events that involve simulating the users' mouse and keyboard events.

Chapter 4, Capturing Errors, focuses on how to handle errors within PhantomJS and those that are generated by the pages.

Chapter 5, Grabbing Pages, plays with one cool feature of PhantomJS, that is, capturing screenshots programmatically.

Chapter 6, Accessing Location-based Services, focuses on using existing web-based and location-based services. Using PhantomJS as our headless browser, we will be capturing location data and creating examples that are useful.

Chapter 7, Working with Files, shows you how to work with files and understand how these are supported by PhantomJS using its own FileSystem API.

Chapter 8, Cookies, discusses how cookies are supported by PhantomJS. We will learn to create cookies and interact with the pages that need them.

Chapter 9, External JavaScript, addresses the subject of working with external JavaScripts and shows how we can create PhantomJS modules that can be re-used in every script.

Chapter 10, Testing with PhantomJS, focuses on the use of PhantomJS for testing. We will learn how to use Jasmine, create test scripts, and make them work using PhantomJS.

Chapter 11, Maximizing PhantomJS, goes over the different products that are written using PhantomJS and shows how we can go beyond what we've learned from the books to make our own applications.