售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Selenium Design Patterns and Best Practices
Table of Contents
Selenium Design Patterns and Best Practices
Credits
Foreword
About the Author
Acknowledgments
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. Writing the First Test
Choosing Selenium over other tools
Right tool for the right job
Price
Open source
Flexibility
The Record and Playback pattern
Advantages of the Record and Playback pattern
Disadvantages of the Record and Playback pattern
Getting started with the Selenium IDE
Installing the Selenium IDE
Recording our first test
Saving the test
Understanding Selenium commands
Reading Selenese
Comparing Ruby to Selenese
Comparing Selenium commands in multiple languages
Writing a Selenium test in Ruby
Introducing Test::Unit
Introducing asserts
Interactive test debugging
Summary
2. The Spaghetti Pattern
Introducing the Spaghetti pattern
Advantages of the Spaghetti pattern
Disadvantages of the Spaghetti pattern
Testing the product review functionality
Starting a product review test
Locating elements on the page
Using a browser's element inspector
Introducing locator strategies
Using advanced locator strategies
Using the absolute path
Using the relative path
Writing locator strategy code
Using chained selector strategy methods
Using the CSS selector
Using XPath
Implementing clicks and assertions
Duplicating the product review test
Reasons for failures
The Chain Linked pattern
The Big Ball of Mud pattern
Summary
3. Refactoring Tests
Refactoring tests
The DRY testing pattern
Advantages of the DRY testing pattern
Disadvantages of the DRY testing pattern
Moving code into a setup and teardown
Removing duplication with methods
Removing external test goals
Using a method to fill out the review form
Reviewing the refactored code
The Hermetic test pattern
Advantages of the Hermetic test pattern
Disadvantages of the Hermetic test pattern
Removing test-on-test dependence
Using timestamps as test data
Extracting the remaining common actions to methods
Creating a new review with a single method call
Reviewing the test-on-test dependency refactoring
Creating generic DRY methods
Refactoring with generic methods
The random run order principle
Advantages of the random run order principle
Disadvantages of the random run order principle
Summary
4. Data-driven Testing
Data relevance versus data accessibility
Hardcoding input data
Hiding test data from tests
Choosing the test environment
Introducing test fixtures
Parsing fixture data
Using fixture data in the tests
Using fixtures to validate products
Testing the remaining products
Multiple test models
A single test model
Implementing multiple test models
Making test failures more expressive
Using an API as a source of fixture data
Using data stubs
The default values pattern
Advantages of the default values pattern
Disadvantages of the default values pattern
Merging the default values pattern and the faker library
Implementing faker methods
Updating the comment test to use default values
Summary
5. Stabilizing the Tests
Engineering the culture of stability
Running fast and failing fast
Running as often as possible
Keeping a clean and consistent environment
Discarding bad code changes
Maintaining a stable test suite
Waiting for AJAX
Testing without AJAX delays
Using explicit delays to test AJAX forms
Implementing intelligent delays
Waiting for JavaScript animations
The Action Wrapper pattern
Advantages of the Action Wrapper pattern
Disadvantages of the Action Wrapper pattern
Implementing the Action Wrapper pattern
The Black Hole Proxy pattern
Advantages of the Black Hole Proxy pattern
Disadvantages of the Black Hole Proxy pattern
Implementing the Black Hole Proxy pattern
Test your tests!
Summary
6. Testing the Behavior
Behavior-driven Development
Advantages of BDD
Disadvantages of BDD
Testing the shopping cart behavior
Describing shopping cart behavior
Writing step definitions
Is BDD right for my project?
Introducing Cucumber
Feature files
Step definition files
The configuration directory
Cucumber.yml
env.rb
Running the Cucumber suite
The write once, test everywhere pattern
Advantages of the write once, test everywhere pattern
Disadvantages of the write once, test everywhere pattern
Testing a mobile site
Updating the Selenium wrapper
Moving step definition files
Updating the Cucumber profile and tagging tests
Running and fixing incompatible steps
Testing the purchase API
Summary
7. The Page Objects Pattern
Understanding objects
Describing a literal object
Object properties
Object actions
Objects within objects
Describing a programming object
Describing a web page with objects
The Page Objects pattern
Advantages of the Page Objects pattern
Disadvantages of the Page Objects pattern
Creating a Page Objects framework
Creating a page super class
Implementing sidebar objects
Implementing the SidebarCart class
Adding Self Verification to pages
Implementing individual page classes
Increasing the number of sidebar objects as the website grows
Running tests with the Page Objects framework
Using Page Objects in the Test::Unit framework
Using Page Objects in different testing frameworks
Looking at the Cucumber implementation
Looking at the RSpec implementation
The test tool independence pattern
Advantages of the test tool independence
Disadvantages of the test tool independence
The right way to implement Page Objects
Making pages smarter than tests
Making tests smarter than pages
Using modules instead of inheritance
Placing logic in Page Objects
Summary
8. Growing the Test Suite
Strategies for writing test suites
Different types of tests
The smoke test suite
The money path suite
New feature growth strategy
Bug-driven growth strategy
The regression suite
The 99 percent coverage suite
Continuous Integration
Managing the test environments and nodes
Deploying new builds
CI environment management
Build node management
Configuration management system
Virtualization
Selenium Grid
Understanding standalone and grid modes
JsonWire protocol
Standalone mode
Grid mode
Installing Selenium Grid
Using Selenium Grid
Selenium Grid Extras
Choosing the CI tool
Decoupling tests from tools
Frequently Asked Questions
How to test on multiple browsers?
Problem
Possible solutions
Localhost testing
Setting up Selenium Grid
Setting up SauceLabs Grid
Which programming language to write tests in?
Should we use Selenium to test the JS functionality?
Problem
Possible solution
Why should I use a headless browser?
Possible solution
PhantomJS
Which BDD tool should I use on my team?
Problem
Possible solutions
Can I use Selenium for performance testing?
Problem
Possible solutions
Summary
A. Getting Started with Selenium
Setting up the computer
Using Command Line Interface
Using the terminal on Windows
Using MS-DOS
Using PowerShell
Using the terminal emulator
Using the terminal on Mac OS X
Using the terminal on Linux
Configuring the Ruby runtime environment
Installing Ruby
Installing the selenium-webdriver gem
Installing Firefox
Understanding test class naming
Naming files
Naming classes
Understanding the namespace
Showing object inheritance
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜