售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
PhantomJS Cookbook
Table of Contents
PhantomJS Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with PhantomJS
Introduction
Installing PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Installing from Source
Launching the PhantomJS REPL
Getting ready
How to do it…
How it works…
Running a PhantomJS script
Getting ready
How to do it…
How it works…
There's more…
See also
Running a PhantomJS script with arguments
Getting ready
How to do it…
How it works…
There's more…
See also
Running PhantomJS with cookies
Getting ready
How to do it…
How it works…
See also
Running PhantomJS with a disk cache
Getting ready
How to do it…
How it works…
There's more…
disk-cache
max-disk-cache-size
Cache locations
See also
Running PhantomJS with a JSON configuration file
Getting ready
How to do it…
How it works…
There's more…
See also
Debugging a PhantomJS script
Getting ready
How to do it…
How it works…
There's more…
remote-debugger-port
remote-debugger-autorun
2. PhantomJS Core Modules
Introduction
Inspecting the version at runtime
Getting ready
How to do it…
How it works…
Managing cookies with the phantom object
Getting ready
How to do it…
How it works…
See also
Specifying a path for external scripts
Getting ready
How to do it…
How it works…
There's more…
phantom.libraryPath
phantom.injectJs
phantom.injectJs versus require
See also
Setting up a global PhantomJS error handler
Getting ready
How to do it…
How it works…
There's more…
onError parameters
See also
Controlling the exit status of a PhantomJS script
Getting ready
How to do it…
How it works…
There's more…
Type coercion with phantom.exit
Inspecting command-line arguments
Getting ready
How to do it…
How it works…
There's more…
Establishing a command-line convention
See also
Inspecting system environment variables
Getting ready
How to do it…
How it works…
There's more…
Saving a file from a PhantomJS script
Getting ready
How to do it…
How it works…
There's more…
exists
makeDirectory
isWritable
write
See also
Reading a file from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
changeWorkingDirectory
open
stream objects
atEnd
readLine
close
Other stream methods
See also
Creating a custom module for PhantomJS
Getting ready
How to do it…
How it works…
See also
Loading custom modules in PhantomJS
Getting ready
How to do it…
How it works…
See also
3. Working with webpage Objects
Introduction
Creating a web page instance in PhantomJS with the webpage module
Getting ready
How to do it…
How it works…
There's more…
The WebPage constructor
Opening a URL within PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Generating a POST request from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Inspecting page content from a PhantomJS script
Getting ready
How to do it…
How it works…
There's more…
Including external JavaScript on the page
Getting ready
How to do it…
How it works…
There's more…
includeJs
injectJs
See also
Recording debugger messages
Getting ready
How to do it…
How it works…
There's more…
See also
Simulating mouse clicks in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Simulating keyboard input in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Simulating scrolling in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Simulating mouse hovers in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Blocking CSS from downloading
Getting ready
How to do it…
How it works…
There's more…
onResourceRequested
onResourceReceived
See also
Causing images to fail randomly
Getting ready
How to do it…
How it works…
There's more…
onResourceError
See also
Submitting Ajax requests from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Working with WebSockets in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
4. Unit Testing with PhantomJS
Introduction
Running Jasmine unit tests with PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Using TerminalReporter for unit testing in PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Creating a Jasmine test runner for PhantomJS and every other browser
Getting ready
How to do it…
How it works…
See also
Running Jasmine unit tests with Grunt
Getting ready
How to do it…
How it works…
There's more…
See also
Watching your tests during development with Grunt
Getting ready
How to do it…
How it works…
There's more…
Running Jasmine unit tests with the Karma test runner
Getting ready
How to do it…
How it works…
There's more…
Generating code coverage reports with Istanbul and the Karma test runner
Getting ready
How to do it…
How it works…
There's more…
Running Jasmine unit tests with Karma and PhantomJS from WebStorm
Getting ready
How to do it…
How it works…
Running QUnit tests with PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Running Mocha unit tests with PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
5. Functional and End-to-end Testing with PhantomJS
Introduction
Running Selenium tests with PhantomJS and GhostDriver
Getting ready
How to do it…
How it works…
There's more…
Using WebdriverJS as a Selenium client for PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Adding Poltergeist to a Capybara suite
Getting ready
How to do it…
How it works…
Taking screenshots during tests with Poltergeist
Getting ready
How to do it…
How it works…
There's more…
See also
Simulating precise mouse clicks with Poltergeist
Getting ready
How to do it…
How it works…
There's more…
See also
Installing CasperJS
Getting ready
How to do it…
How it works…
There's more…
Interacting with web pages using CasperJS
Getting ready
How to do it…
How it works…
There's more…
See also
End-to-end testing with CasperJS
Getting ready
How to do it…
How it works…
There's more…
See also
Exporting test results from CasperJS in the XUnit format
Getting ready
How to do it…
How it works…
See also
Detecting visual regressions using PhantomCSS
Getting ready
How to do it…
How it works…
There's more…
See also
6. Network Monitoring and Performance Analysis
Introduction
Generating HAR files from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Listing CSS properties
Getting ready
How to do it…
How it works…
There's more…
See also
Generating an appcache manifest
Getting ready
How to do it…
How it works…
There's more…
Configuration options
See also
Executing a simple performance analysis
Getting ready
How to do it…
How it works…
There's more…
Configuration options
See also
Executing a detailed performance analysis
Getting ready
How to do it…
How it works…
There's more…
Information
Format
Ruleset
User agent
Viewport
Headers
CDNs
See also
Executing a YSlow performance analysis with a custom ruleset
Getting ready
How to do it…
How it works…
There's more…
See also
Automating performance analysis with YSlow and PhantomJS
Getting ready
How to do it…
How it works…
There's more…
Using TAP format
See also
7. Generating Images and Documents with PhantomJS
Introduction
Rendering images from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Saving images as Base64 from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Rendering and rasterizing SVGs from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
Generating clipped screenshots from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
CasperJS
See also
Saving a web page from PhantomJS as a PDF
Getting ready
How to do it…
How it works…
There's more…
webpage.paperSize
width and height
format
orientation
border
See also
Applying custom headers and footers to PDFs generated from PhantomJS
Getting ready
How to do it…
How it works…
There's more…
height
contents
See also
Testing responsive designs with PhantomJS
Getting ready
How to do it…
How it works…
There's more…
See also
8. Continuous Integration with PhantomJS
Introduction
Setting up PhantomJS in a CI environment
Getting ready
How to do it…
How it works…
There's more…
See also
Generating JUnit reports
Getting ready
How to do it…
How it works…
There's more…
See also
Generating TAP reports
Getting ready
How to do it…
How it works…
See also
Setting up a fully covered project in CI with PhantomJS
Getting ready
How to do it…
How it works…
See also
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜