وبلاگ بلیان

Getting Started with PhantomJS

معرفی کتاب «Getting Started with PhantomJS» نوشتهٔ Aries Beltran، منتشرشده توسط نشر Packt Publishing در سال 2013. این کتاب در 2 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «Getting Started with PhantomJS» در دستهٔ بدون دسته‌بندی قرار دارد.

Harness the strength and capabilities of PhantomJS to interact with the web and perform website testing with a headless browser based on WebKit **Overview** * Writing scripts that can interact directly with web services and pages * Interacting with social media websites using PhantomJS scripts * Creating web-based test scripts and running them in a headless browser **In Detail** 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. **What you will learn from this book** * Explore the possibilities of PhantomJS development and make use of a headless browser * Understand PhantomJS’ core features and API * Manipulate the DOM properties of web pages using scripts * Interact with web pages using PhantomJS scripts * Learn how to emulate keyboards and mouse actions * Work with geolocation services with PhantomJS * Build scripts that will create web sites snapshots * Create and implement PhantomJS custom modules * Use PhantomJS to perform headless testing with Jasmine **Approach** A standard tutorial approach, as a complete guide detailing the major aspects of PhantomJS with particular focus on website testing. **Who this book is written for** If you are a JavaScript developers who is interested in developing applications that interact with various web services, using a headless browser, then this book is ideal for you. This book will also be good for you if you are planning to create a headless browser testing for your web application. Basic understanding of JavaScript is assumed. Annotation Harness the strength and capabilities of PhantomJS to interact with the web and perform website testing with a headless browser based on WebKit Overview Writing scripts that can interact directly with web services and pages Interacting with social media websites using PhantomJS scripts Creating web-based test scripts and running them in a headless browser In Detail 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. What you will learn from this book Explore the possibilities of PhantomJS development and make use of a headless browser Understand PhantomJS core features and API Manipulate the DOM properties of web pages using scripts Interact with web pages using PhantomJS scripts Learn how to emulate keyboards and mouse actions Work with geolocation services with PhantomJS Build scripts that will create web sites snapshots Create and implement PhantomJS custom modules Use PhantomJS to perform headless testing with Jasmine Approach A standard tutorial approach, as a complete guide detailing the major aspects of PhantomJS with particular focus on website testing. Who this book is written for If you are a JavaScript developers who is interested in developing applications that interact with various web services, using a headless browser, then this book is ideal for you. This book will also be good for you if you are planning to create a headless browser testing for your web application. Basic understanding of JavaScript is assumed Cover 1 Copyright 3 Credits 4 About the Author 5 About the Reviewers 6 www.PacktPub.com 7 Table of Contents 8 Preface 12 Chapter 1: Getting Started with PhantomJS 18 Downloading PhantomJS 18 Building PhantomJS from source 19 Meet PhantomJS 20 PhantomJS JavaScript API 24 The Module API 25 The WebPage API 25 The System API 25 The FileSystem API 25 The WebServer API 26 The phantom object 26 The command-line arguments 26 The script argument 27 The debug option 27 The cookie-file option 27 Writing PhantomJS scripts 27 Summary 28 Chapter 2: Manipulating Page Content 30 Opening a web page 30 Playing with DOM elements 33 Selecting elements 33 Simulating mouse clicks 41 PhantomJS event triggering 41 DOM event triggering 44 Working with form fields 45 Summary 50 Chapter 3: Handling Events and Callbacks 52 Listening to page events 52 Page load events 52 When a resource is requested 54 Receiving a page resource 56 Two stages of the resource received event 59 Knowing when the URL changes 62 Capturing alert messages 63 Answering prompt messages 64 OK or Cancel – responding to confirm pop ups 64 Performing user events 65 Keyboard events 65 Mouse events 68 Summary 69 Chapter 4: Capturing Errors 70 Handling PhantomJS errors 70 Capturing page script errors 73 Anticipating the page loading error 75 Exiting with error codes 77 Summary 77 Chapter 5: Grabbing Pages 78 Undocumented supported image format 81 Screenshot dimensions 82 Saving webpages as PDFs 84 Summary 85 Chapter 6: Accessing Location-based Services 86 Checking a location based on IP address 86 Getting driving directions 88 Looking up for pizza delivery establishments 91 Summary 93 Chapter 7: Working with Files 94 PhantomJS FileSystem API 94 Reading files 95 Checking for file existence 95 Opening the file 96 Closing the opened files 98 Writing files 98 Character encoding 99 Summary 99 Chapter 8: Cookies 100 Reading cookies 100 Baking some cookies 102 Deleting cookies 104 Keeping cookies 104 Summary 104 Chapter 9: External JavaScript 106 Modules 106 Using the object-oriented modules 109 Using third-party JavaScript libraries 111 Summary 112 Chapter 10: Testing with PhantomJS 114 What is unit testing? 114 Unit testing with Jasmine 114 Downloading Jasmine 116 Test specs with Jasmine 116 The PhantomJS Jasmine runner 122 Summary 127 Chapter 11: Maximizing PhantomJS 128 CasperJS 128 GhostDriver 131 Screenshots, web metrics, and more 131 Summary 132 Index 134

In Detail

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.

Approach

A standard tutorial approach, as a complete guide detailing the major aspects of PhantomJS with particular focus on website testing.

Who this book is for

If you are a JavaScript developers who is interested in developing applications that interact with various web services, using a headless browser, then this book is ideal for you. This book will also be good for you if you are planning to create a headless browser testing for your web application. Basic understanding of JavaScript is assumed.

The book will follow aA standard tutorial approach, and will beas a complete guide detailing the major aspects of PhantomJS with particular focus on Website website Testingtesting. This book is written forIf you are a JavaScript developers who are is interested in developing applications that interact with various web services, and doing that using a headless browser, then this book is ideal for you. This book iswill also be good for you if you are planning to create a headless browser testing for your web application. Basic understanding of JavaScript is assumed.
دانلود کتاب Getting Started with PhantomJS