PhantomJS Cookbook


PhantomJS Cookbook
eBook: $25.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.09
save 15%!
Print + free eBook + free PacktLib access to the book: $67.98    Print cover: $41.99
$41.99
save 38%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn the fundamentals of working with the headless PhantomJS browser
  • Create unit and functional test suites backed by PhantomJS
  • Integrate PhantomJS into development and testing workflows for efficient unit testing

Book Details

Language : English
Paperback : 304 pages [ 235mm x 191mm ]
Release Date : June 2014
ISBN : 178398192X
ISBN 13 : 9781783981922
Author(s) : Rob Friesel
Topics and Technologies : All Books, Web Development, Cookbooks, Open Source


Table of Contents

Preface
Chapter 1: Getting Started with PhantomJS
Chapter 2: PhantomJS Core Modules
Chapter 3: Working with webpage Objects
Chapter 4: Unit Testing with PhantomJS
Chapter 5: Functional and End-to-end Testing with PhantomJS
Chapter 6: Network Monitoring and Performance Analysis
Chapter 7: Generating Images and Documents with PhantomJS
Chapter 8: Continuous Integration with PhantomJS
Index
  • Chapter 1: Getting Started with PhantomJS
    • Introduction
    • Installing PhantomJS
    • Launching the PhantomJS REPL
    • Running a PhantomJS script
    • Running a PhantomJS script with arguments
    • Running PhantomJS with cookies
    • Running PhantomJS with a disk cache
    • Running PhantomJS with a JSON configuration file
    • Debugging a PhantomJS script
  • Chapter 2: PhantomJS Core Modules
    • Introduction
    • Inspecting the version at runtime
    • Managing cookies with the phantom object
    • Specifying a path for external scripts
    • Setting up a global PhantomJS error handler
    • Controlling the exit status of a PhantomJS script
    • Inspecting command-line arguments
    • Inspecting system environment variables
    • Saving a file from a PhantomJS script
    • Reading a file from PhantomJS
    • Creating a custom module for PhantomJS
    • Loading custom modules in PhantomJS
  • Chapter 3: Working with webpage Objects
    • Introduction
    • Creating a web page instance in PhantomJS with the webpage module
    • Opening a URL within PhantomJS
    • Generating a POST request from PhantomJS
    • Inspecting page content from a PhantomJS script
    • Including external JavaScript on the page
    • Recording debugger messages
    • Simulating mouse clicks in PhantomJS
    • Simulating keyboard input in PhantomJS
    • Simulating scrolling in PhantomJS
    • Simulating mouse hovers in PhantomJS
    • Blocking CSS from downloading
    • Causing images to fail randomly
    • Submitting Ajax requests from PhantomJS
    • Working with WebSockets in PhantomJS
  • Chapter 4: Unit Testing with PhantomJS
    • Introduction
    • Running Jasmine unit tests with PhantomJS
    • Using TerminalReporter for unit testing in PhantomJS
    • Creating a Jasmine test runner for PhantomJS and every other browser
    • Running Jasmine unit tests with Grunt
    • Watching your tests during development with Grunt
    • Running Jasmine unit tests with the Karma test runner
    • Generating code coverage reports with Istanbul and the Karma test runner
    • Running Jasmine unit tests with Karma and PhantomJS from WebStorm
    • Running QUnit tests with PhantomJS
    • Running Mocha unit tests with PhantomJS
  • Chapter 5: Functional and End-to-end Testing with PhantomJS
    • Introduction
    • Running Selenium tests with PhantomJS and GhostDriver
    • Using WebdriverJS as a Selenium client for PhantomJS
    • Adding Poltergeist to a Capybara suite
    • Taking screenshots during tests with Poltergeist
    • Simulating precise mouse clicks with Poltergeist
    • Installing CasperJS
    • Interacting with web pages using CasperJS
    • End-to-end testing with CasperJS
    • Exporting test results from CasperJS in the XUnit format
    • Detecting visual regressions using PhantomCSS
  • Chapter 6: Network Monitoring and Performance Analysis
    • Introduction
    • Generating HAR files from PhantomJS
    • Listing CSS properties
    • Generating an appcache manifest
    • Executing a simple performance analysis
    • Executing a detailed performance analysis
    • Executing a YSlow performance analysis with a custom ruleset
    • Automating performance analysis with YSlow and PhantomJS
  • Chapter 7: Generating Images and Documents with PhantomJS
    • Introduction
    • Rendering images from PhantomJS
    • Saving images as Base64 from PhantomJS
    • Rendering and rasterizing SVGs from PhantomJS
    • Generating clipped screenshots from PhantomJS
    • Saving a web page from PhantomJS as a PDF
    • Applying custom headers and footers to PDFs generated from PhantomJS
    • Testing responsive designs with PhantomJS

Rob Friesel

Rob Friesel is a senior user interface developer and 10-year veteran at Dealer.com, where he develops UI frameworks and toolkits for their enterprise platform. He blogs about and presents on a variety of technologies, but his first love is the front-end. He has contributed as a credited reviewer to several books on JavaScript and one on Clojure. He tweets at @founddramaand blogs at http://blog.founddrama.net/.
Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

PhantomJS Cookbook +    Mastering Object-oriented Python =
50% Off
the second eBook
Price for both: $35.95

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Develop your own PhantomJS core modules
  • Learn sophisticated strategies for interacting with web page contents and how to capture those interactions
  • Create a front-end continuous integration (CI) strategy with PhantomJS
  • Perform unit testing with frameworks such as Jasmine, Mocha, and QUnit
  • Implement functional and end-to-end testing with PhantomJS using tools such as Selenium, Capybara, and CasperJS
  • Automate performance analysis with libraries such as Confess.js and YSlow
  • Automate the generation of images and PDFs of your web content

In Detail

Beginning with the basics of PhantomJS, this book will dive into its core modules and guide you through how to solve real-world testing problems. This book explores a variety of test automation tasks, including executing JavaScript unit tests with the Jasmine, QUnit, and Mocha frameworks; functional tests with tools such as Selenium, Capybara, and CasperJS; performance analysis with tools such as YSlow; and much more.

If you are a web developer looking to run automated unit tests while you work, or perhaps you are a QA engineer looking for a fast test automation utility, then this book is perfect for you. Some prior knowledge of JavaScript would be helpful.

Approach

A task-based guide that provides solutions to real-world test automation problems.

Who this book is for

This book is intended for web development professionals who want to integrate PhantomJS into their development and testing workflows. If you are a web developer looking to run automated unit tests while you work, or perhaps you are a QA engineer looking for a fast test automation utility, then this book is perfect for you. Some prior knowledge of JavaScript would be helpful.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software