0% found this document useful (0 votes)
4 views

67589500

The document is a promotional material for various ebooks related to automated testing and design patterns, including 'Design Patterns for High-Quality Automated Tests' by Anton Angelov. It provides links to download the ebooks in multiple formats and outlines the content covered in the featured book, including chapters on test attributes, optimization, maintainability, and best practices. Additionally, it includes information about the author and reviewers, as well as a brief overview of the topics discussed in the book.

Uploaded by

etnikbrowes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

67589500

The document is a promotional material for various ebooks related to automated testing and design patterns, including 'Design Patterns for High-Quality Automated Tests' by Anton Angelov. It provides links to download the ebooks in multiple formats and outlines the content covered in the featured book, including chapters on test attributes, optimization, maintainability, and best practices. Additionally, it includes information about the author and reviewers, as well as a brief overview of the topics discussed in the book.

Uploaded by

etnikbrowes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Download the Full Ebook and Access More Features - ebooknice.

com

(Ebook) Design Patterns for High-Quality Automated


Tests: High-Quality Test Attributes and Best
Practices by Anton Angelov

https://ebooknice.com/product/design-patterns-for-high-
quality-automated-tests-high-quality-test-attributes-and-
best-practices-33794750

OR CLICK HERE

DOWLOAD EBOOK

Download more ebook instantly today at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Design Patterns for High-Quality Automated Tests:


High-Quality Test Attributes and Best Practices by Unknown
ISBN 9798715639523, 8715639525, B08XWFM6V8
https://ebooknice.com/product/design-patterns-for-high-quality-
automated-tests-high-quality-test-attributes-and-best-
practices-33794754
ebooknice.com

(Ebook) Selenium design patterns and best practices build


a powerful, stable, and automated test suite using
Selenium WebDriver by Kovalenko, Dima ISBN 9781783982707,
9781783982714, 1783982705, 1783982713
https://ebooknice.com/product/selenium-design-patterns-and-best-
practices-build-a-powerful-stable-and-automated-test-suite-using-
selenium-webdriver-11860656
ebooknice.com

(Ebook) Meta-algorithmics : patterns for robust, low cost,


high quality systems by Simske, Steven J ISBN
9781118343364, 9781118626696, 9781118626702,
9781118626726, 1118343360, 1118626699, 1118626702,
https://ebooknice.com/product/meta-algorithmics-patterns-for-robust-
1118626729
low-cost-high-quality-systems-5428854

ebooknice.com

(Ebook) High-Quality, High-Volume Spay and Neuter and


Other Shelter Surgeries by Sara White (editor) ISBN
9781118517208, 1118517202
https://ebooknice.com/product/high-quality-high-volume-spay-and-
neuter-and-other-shelter-surgeries-11363604

ebooknice.com
(Ebook) The Understanding by Design Guide to Creating
High-Quality Units by Grant Wiggins, Jay McTighe ISBN
9781416611493, 1416611495
https://ebooknice.com/product/the-understanding-by-design-guide-to-
creating-high-quality-units-42300862

ebooknice.com

(Ebook) JUNOS High Availability: Best Practices for High


Network Uptime by James Sonderegger, Orin Blomberg, Kieran
Milne, Senad Palislamovic ISBN 9780596523046, 0596523041
https://ebooknice.com/product/junos-high-availability-best-practices-
for-high-network-uptime-4681878

ebooknice.com

(Ebook) Best Management Practices for Forestry: Protecting


Maine's Water Quality by Morten Moesswilde, Maine Forest
Service
https://ebooknice.com/product/best-management-practices-for-forestry-
protecting-maine-s-water-quality-52333634

ebooknice.com

(Ebook) Reading for Life: High Quality Literacy


Instruction for All by Lyn Stone ISBN 9781138590908,
9781138590922, 1138590908, 1138590924
https://ebooknice.com/product/reading-for-life-high-quality-literacy-
instruction-for-all-34774830

ebooknice.com

(Ebook) Puppet Best Practices: Design Patterns for


Maintainable Code by Chris Barbour ISBN 9781491923009,
1491923008
https://ebooknice.com/product/puppet-best-practices-design-patterns-
for-maintainable-code-7378926

ebooknice.com
Design Patterns
For High-Quality
Automated Tests
C# Edition
High-Quality Test Attributes
and Best Practices

Anton Angelov
Automate The Planet
Table of Contents
Credits
About the Author
About the Reviewers
Acknowledgements
Foreword
Preface
What this book covers
Chapter 1. Defining High-Quality Test Attributes
Chapter 2. Optimizing and Refactoring Legacy Flaky Tests
Chapter 3. Strategies for Speeding-up the Tests
Chapter 4. Test Readability
Chapter 5. Enhancing the Test Maintainability and Reusability
Chapter 6. API Usability
Chapter 7. Building Extensibility in Your Test Library
Chapter 8. Assessment System for Tests’ Architecture Design
Chapter 9. Benchmarking for Assessing Automated Test Components Performance
Chapter 10. Test Data Preparation and Configuring Test Environments
Appendix 1. Defining the Primary Problems that Test Automation Frameworks Solve
Appendix 2. Most Exhaustive CSS Selectors Cheat Sheet
Appendix 3. Most Exhaustive XPath Selectors Cheat Sheet
Who Is This Book For?
Before You Get Started
Conventions
Reader feedback
Errata
Piracy
Questions
Chapter 1. Defining High-Quality Test Attributes
Different Types of Tests
Unit Tests
Integration Tests
System Tests
What Is a Test Automation Framework?
What Is a Software Library?
What Is a Framework?
Test Automation Framework
Is Selenium WebDriver a Test Framework?
SOLID Principles
SRP – Single Responsibility Principle
OCP – Open/Closed Principle
LSP – Liskov Substitution Principle
ISP – Interface Segregation Principle
DIP – Dependency Inversion Principle
High-Quality Test Attributes
What Is a Design Pattern?
Test Maintainability and Reusability
Test Readability
API Usability
Extensibility
Learning Curve
Summary
Questions
Further Reading
Chapter 2. Optimizing and Refactoring Legacy Flaky Tests
Writing the First Real-World Automated Test
First Automated Test Case Explanation
Second Automated Test Case Explanation
Third Automated Test Case Explanation
First Automated Test Code
Second Automated Test Code
Third Automated Test Code
Reasons for Failures
Refactoring Tests
Implicit VS Explicit Waits
Implementing Explicit Waits in Tests
DRY- Do Not Repeat Yourself Principle
Decorator Design Pattern for Fixing WebDriver Unstable Actions
Decorator Design Pattern
Decorator Design Pattern Implementation for IWebElement
Decorator Design Pattern Implementation for IWebDriver
Decorator Design Pattern in Tests
Test Independence- Isolation Principle
Refactoring Tests to Follow Test Independence- Isolation Principle
Summary
Questions
Further Reading
Chapter 3. Strategies for Speeding-up the Tests
Instrumenting the Test Code to Find Possible Points for Optimization
Optimize Login
How to Wait for Asynchronous Requests to Finish in Tests?
Waiting for All AJAX Requests Completion
Optimize Browser Initialization- Observer Design Pattern
Observer Design Pattern
Observer Design Pattern Implementation
Configure Browser Behavior via Attribute
Isolated Browser Initialization for Each Test
Black Hole Proxy Approach
Implementing the Black Hole Proxy
Summary
Questions
Further Reading
Chapter 4. Test Readability
Page Object Model Design Pattern
Create First Page Object Model
New Way for Creating Page Objects
Page Object Model Usage in Tests
Handling Common Page Elements and Actions
Defining Common Page Elements
Non-DRY Page Objects
First Version of Reusing Common Elements
Creating Common Page Section Page Objects
Page Sections Usage in Page Objects - Version One
Page Sections Usage in Page Objects - Version Two
Page Sections Usage in Tests
High Quality Code - Use Meaningful Names
General Naming Guidelines
Naming Classes
Naming New Versions of Existing API
Naming the Methods - The Right Way
General Naming Guidelines
Using Meaningful Method Names
Best Practices for Method Parameters
Follow Coding Standards - Tools
Enforcing Coding Standards Using EditorConfig
Summary
Questions
Further Reading
Chapter 5. Enhancing the Test Maintainability and Reusability
Navigatable Page Objects- Template Method Design Pattern
Non-refactored Version Page Objects
Create Separate Base Classes for Navigatable and Non-navigatable Pages
Template Method Design Pattern
Template Method Design Pattern Implementation
Using Composition Principle
Non-refactored Version Page Objects without Composition
Elements and Assertions - Composition Implementation
Using Composition in Tests
Reuse Test Workflows - Facade Design Pattern
Test Workflows Naive Implementation
Facade Design Pattern
Facade Design Pattern Implementation
Combining Facade with Template Method Design Pattern
Purchase Facade with Template Methods
Concrete Facade Implementation
Summary
Questions
Further Reading
Chapter 6. API Usability
Interface Segregation principle for WebDriver Decorator
WebDriver Decorator Current Implementation
Splitting Driver Interface into Smaller Interfaces
Smaller Interfaces Usage in Page Objects
Use Page Objects Through Singleton Design Pattern
Singleton Design Pattern
Singleton Design Pattern Implementation
Thread-safe Singleton Implementation
Singleton Design Pattern Usage in Tests
App Design Pattern for Creating Page Objects
App Design Pattern Implementation
App Usage in Tests
Fluent API Page Objects
Fluent API Implementation
Using Fluent API in Tests
Page Objects Elements Access Styles
Exposing Elements Through Properties
Accessing Elements Through Elements Public Property
Hiding Elements in Tests
Hiding Element Unnecessary Details
Summary
Questions
Further Reading
Chapter 7. Building Extensibility in Your Test Library
Building Extensibility for Finding Elements through Strategy Design Pattern
Vanilla WebDriver Finding of Elements
Strategy Design Pattern
Reviewing Current Version for Finding Elements
Creating Elements Find Strategies
Refactoring IElementFindService
Improving Elements Find Strategies API Usability
Building Extensibility for Waiting for Elements through Strategy Design Pattern
Vanilla WebDriver Waiting for Elements
Reviewing Current Version of Elements Waiting
Creating Elements Wait Strategies
Creating IElementWaitService
Adding Waiting for Elements to ElementFinderService
Adding Extensibility Points through EventFiringWebDriver
Vanilla EventFiringWebDriver Example
Integrating EventFiringWebDriver
Summary
Questions
Further Reading
Chapter 8. Assessment System for Test Architecture Design
Assessment System Introduction
What Problem Are We Trying to Solve?
Criteria Definitions
1. Readability
2. Maintainability
3. Reusability
4. API Usability
5. Extensibility
6. Code Complexity Index
7. Learning Curve
8. KISS*
Steps to Apply
Assessment System Usage Examples
Tests without Page Objects Assessment
Architecture Design Overview
1. Readability
2. Maintainability
3. Reusability
4. API Usability
5. Extensibility
6. Code Complexity Index
7. Learning Curve
Test Design Index
Tests with Page Objects Assessment
Architecture Design Overview
1. Readability
2. Maintainability
3. Reusability
4. API Usability
5. Extensibility
6. Code Complexity Index
7. Learning Curve
Test Design Index
Tests with Facades Assessment
Architecture Design Overview
1. Readability
2. Maintainability
3. Reusability
4. API Usability
5. Extensibility
6. Code Complexity Index
7. Learning Curve
Test Design Index
Final Assessment
Summary
Questions
1. Can you list the seven criteria of the assessment system?
2. What aspects of the code do you evaluate for the Reusability
criterion?
3. Why is the learning curve a critical evaluation point?
4. What is the Test Design Index?
5. How do you calculate code metrics in Visual Studio IDE?
6. What steps do you need to follow to apply the assessment system in
your project?
Further Reading
Chapter 9. Benchmarking for Assessing Automated Test Components
Performance
What Is Benchmarking?
Benchmarking Your .NET Code with BenchmarkDotNet
Main Features
BenchmarkDotNet Example
Benchmark Button Click Solutions
Button Benchmark Experiment
Benchmark Reports, Profiling, Disassembly Diagnoser
Benchmark HTML and CSV Reports
Benchmark Disassembler
Benchmark Profiling
Optimized Browser Initialization Benchmark Integration
Updates in Observer Classes
Summary
Questions
Further Reading
Chapter 10. Test Data Preparation and Test Environments
Stop Hard-coding Input Data
Problematic Test Data
Configuration Transformations
Creating URL Settings
Creating WebDriver Timeouts Settings
Creating Default Billing Info Settings
Environmental Variables
Introducing Test Fixtures
Using AutoFixture for Generating Data
Using MSTest Data Driven Tests
Using an API as a Source of Fixture Data
Using Data Stubs
Building Test Data Reset/Creating App Use Case
Creating DB Access Layer
Generic Repository Design Pattern
Generic Repository Design Pattern in C#
Creating Users Factory
Using an API or DB for Verification
Summary
Questions
Further Reading
Appendix 1. Defining the Primary Problems that Test Automation
Frameworks Solve
Sub Problem 1 - Repetition and People Boredom, Less Reliable
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 2 - Engineers Are Not So Good with Numbers, Accuracy
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 3 - Time for Feedback- Release
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 4 - Regression Issues Prevention
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 5 - Skipping Part of the Scope
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 6 - Ping-pong
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 7 - Money, Time, Effort for Maintaining Test Artifacts
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 8 - Various App Configurations
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 9 - Low QA Team Morale
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 10 - Questioned Professionalism
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 11 - Provide Evidence What You Did
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 12 - Holidays and Sickness, 24 Hours
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 13 - Some Things Cannot be Tested Manually
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 14 – Consistency
Automation Solution Hypothesis
Subsequent Problems
Sub-Problem 15 - Faster Scale-up and Scale-down
Automation Solution Hypothesis
Subsequent Problems
Summary
Further Reading
Appendix 2. Most Exhaustive CSS Selectors Cheat Sheet
Element Selectors
Contextual Selectors
Attribute Selectors
Useful n Values
Pseudo-class Selectors that Apply to Siblings
Pseudo-class Selectors for Link and User States
Further Reading
Appendix 3. Most Exhaustive XPath Selectors Cheat Sheet
Contextual Selectors
Attribute Selectors
XPath Methods
Axis Navigation
Math Methods
String Methods
Further Reading
Bibliography
Credits
Copyright @ 2020 Automate The Planet
All rights reserved. No part of this book may be reproduced, stored in a
retrieval system, or transmitted in any form or by any means, without the
prior written permission of the author, except in the case of brief quotations
embedded in critical articles or reviews. Every effort has been made in the
preparation of this book to ensure the accuracy of the information presented.
However, the information contained in this book is sold without warranty,
either express or implied. Neither the author, nor Automate The Planet, and
its dealers and distributors will be held liable for any damages caused or
alleged to be caused directly or indirectly by this book.
The author has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of
capitals. However, the author cannot guarantee the accuracy of this
information.
First published: February 2020
Production reference: Published by Automate The Planet Ltd.
Address: https://www.automatetheplanet.com/
Book cover design and formatting by Martin Kolev
About the Author
Anton Angelov is CTO and Co-founder of Automate The Planet, inventor of
BELLATRIX Test Automation Framework, and MEISSA Distributed Test
Runner. Anton has 10 years of experience in the field of automated testing.
He designs and writes scalable test automation solutions and tools. He
consults and trains companies regarding their automated testing efforts. Part
of his job is to lead a team of passionate engineers helping companies
succeed with their test automation using the company's BELLATRIX tooling.
He is most famous for his blogging at Automate The Planet and many given
conference talks.
About the Reviewers
Ventsislav Ivanov is a Software Engineer in Tests at Innovative Lab and
Automate The Planet. He starts his automation career from his hobby -
browser games. For the last 6 years in the IT industry, he has achieved a lot
like QA Engineer, Developer, and Lecturer. He has more than 1000 hours
like a lecturer in various disciplines - C# Fundamentals, C# OOP, C# Web,
Java OOP, High-Quality Code, and of course, Quality Assurance. He is a
proud creator and lead of the main Quality Assurance course in one of the
best Bulgarian's academies, where more than 1000+ people certified like QA
engineers and more than 500+ like automation engineers. He has specialized
mainly in web automated testing. He has been responsible for building the
entire QA process in his past company, from teaching developers unit testing
to designing the whole product Continuous Integration. His motto is: "Instead
of feeling embarrassed about your “bad” code or proud of your “good” code,
you should judge your code by how well it succeeds at achieving your goals."
A few words for the book:
Amazing amount of design patterns and best practices in so little space. I
don't know how to describe who this book is for. If you are an experienced
automation engineer who wants to improve his/her company's test automation
framework, this book is a must-read. If you are a beginner in automation, this
book can be an excellent start because of the ladder which you need to climb
until reading it.
Nikolay Avramov is currently a Developer in Test at Innovative Lab and
Automate The Planet. For the past 8 years, he worked as a Quality Assurance
Engineer in Telerik (later acquired by Progress software). He started his
career in the field from ground zero- from taking part of the Telerik Academy
to becoming a Principal QA Engineer/Ninja that is in the heart of any
innovation or automation initiative. Through his work he has developed, and
integrated multiple custom frameworks and tools used across the entire
company. To name a few- a custom Load and Performance Testing
Framework; System Testing Framework; Web Service Testing Framework;
Visual Verification Framework; and many other productivity tools that
assured the highest quality of all web and business assets of the company. He
found his true passion in Automation while looking for a ‘weapon’ to fight
the boring, non-productive daily tasks that a QA faces. By reducing the
manual repeatable jobs, he believes that we can make the world a better
place, full of happy and productive people that are ready to tackle the next
challenging task, instead of the next pile of test scenarios to cover by hand.
He is a passionate technology geek and automation specialist that strives to
implement optimizations and achieve high-quality standards in any aspect of
life.
A few words for the book:
The book will pretty much give you the building blocks you need and will
take you through the natural process of building a fully fletched test
automation framework within a few hour’s read. The beginning and the end
of the book shows the difference between the rookie QA enthusiast and the
automation ninja. This knowledge will give you the power to make educated
decisions for common problems in test automation and will give you the right
arguments to defend them in front of any manager or developer.
Acknowledgements
The content of the book is a result of the accumulated knowledge of many
great engineers and IT professionals. Many good programmers tend to be
very egocentric, believing that they are always right and know everything.
Often, they forget how they got their knowledge. It is a result not only of our
efforts but a mixture of personal effort/work, luck, living, and working
environment. I believe that in this phase of my life, I know enough "tips and
tricks" so that I can write a book. However, this wouldn't be possible without
the help of all the people that took some part of my life. The example and
hard work of my parents, high school, and university teachers. Later, the
many mentors and colleagues I had in the past companies I worked for. I am
a person who is a natural learner and regularly reads new books and watches
video courses/lectures. I wouldn't be as good as I am now without the
valuable information in these materials.
As some of you know, for the past several years, I am regularly writing
articles on my website- Automate The Planet. The book accumulates a big
part of the knowledge I tried to share during the years. But the site wouldn't
be what it is without your support! So, I would like to say, "Thank You!" to
all fans and readers. The same is valid for all the talks I gave to many
international DEV and QA conferences. Thank you for being there, hearing
and trying to apply the ideas I talk about.
Most importantly, I want to say BIG THANK YOU to my colleagues
Nikolay Avramov and Ventsislav Ivanov for agreeing to help me with the
technical and editorial tasks. Without their help and support, the quality of
the book wouldn't be the same!
My partner in crime at Automate The Planet Martin Kolev is responsible for
all visual enhancements, the marketing, and many other tedious tasks around
the project.
Thanks to all my friends that were there for me and hearing me talking geek
stuff about the book.
Foreword
Since I usually skip the Foreword chapters of other books, I will try to be
short. My core belief is that to achieve high-quality test automation that
brings value- you need to understand core programming concepts such as
SOLID and the usage of design patterns. After you master them, the usual
career transition is into more architecture roles, such as choosing the best
possible approaches for solving particular test automation challenges. This is
the essence of the book. No more “Hello world” examples but some
serious literature about test automation practices!
Preface
Design Patterns for High-Quality Automated Tests will help you write better
tests!

What this book covers


Chapter 1. Defining High-Quality Test Attributes
I think many terms are misunderstood and engineers are using them without
fully understanding them, such as a library, framework, test framework. I
believe this is the basic knowledge that all test engineers should have. The
reader will learn about the top-quality attributes each test library should strive
to have, which we will discuss in much more detail in the next chapters.
Moreover, since we want to treat the test code as production one, we will talk
about SOLID principles and how we can incorporate them into the
development of the tests.
Chapter 2. Optimizing and Refactoring Legacy Flaky Tests
We will discuss the Hermetic test pattern where each test should be isolated
from others. Will learn about the Adapter design pattern where some of the
unstable behaviours of WebDriver will be wrapped in a class and fixed. The
same pattern will be used to improve the WebDriver API for locating
elements and making it easier to use. Finally, we will talk about random run
order principle where the tests should be able to run no matter their order.
Chapter 3. Strategies for Speeding-up the Tests
After the tests are stabilized and always passing the next step is to improve
their speed. One of the approaches will be login to a website through cookies
instead of using the UI. Next, the readers will see how to reuse the
WebDriver browser instead of restarting it all the time earning more than
40% decrease in test execution time. We will talk about how to handle
asynchronous requests. And last but not least we will mention the “Black
Hole Proxy” approach isolating 3rd party services’ requests, while further
improving the speed of the automated tests.
Chapter 4. Test Readability
Learn how to hide nitty-gritty low-level WebDriver API details in the so-
called page objects, making the tests much more readable. Also, the readers
will see how to create two different types of page objects depending on their
needs. In the second part of the chapter, we will talk about coding standards -
naming the variables and methods right, as well as placing the correct
comments. At the end of the section, we will discuss various tools that can
help us to enforce all these standards.
Chapter 5. Enhancing the Test Maintainability and Reusability
We will talk about how to reuse more code across page objects by using the
Template Method design pattern. Also, we will see a 3rd type of page object
model where the assertions and elements will be used as properties instead of
coming from base classes, which will introduce the benefits of the
composition over the inheritance principle. In the second part of the chapter,
we will discuss how to reuse common test workflows through the Facade
design pattern. At the end of the section, we will talk about an enhanced
version of the pattern where we can test different versions of the same web
page (new and old).
Chapter 6. API Usability
In this chapter, we will learn how to make the test library API easy to use,
learn, and understand. First, we will talk about different approaches on how
to use already developed page object models through the Singleton design
pattern or Factory design pattern. After that, we will look at another approach
called Fluent API or Chaining Methods. At the end of the section, we will
discuss whether it is a good idea to expose the page objects elements to the
users of your test library.
Chapter 7. Building Extensibility in Your Test Library
If you create a well-designed library, most probably other teams can start
using it too, so you need to be sure that your library is easily extensible. It
should allow everyone to modify it and add new features to it without causing
you to spend tons of time rewriting existing logic or making already written
tests to fail. In this chapter, the reader will learn how to improve extensibility
for finding elements by creating custom selectors through the Strategy design
pattern. After that, we will investigate ways on how we can add additional
behaviors to existing WebDriver actions via Observer design pattern or built-
in EventFiringWebDriver.
Chapter 8. Assessment System for Tests’ Architecture Design
In this chapter, we will look into an assessment system that can help you
decide which design solution is better- for example, to choose one between 5
different versions of page objects. We will talk about the various criteria of
the system and why they are essential. In the second part of the section, we
will use the system to evaluate some of the design patterns we used
previously and assign them ratings.

Chapter 9. Benchmarking for Assessing Automated Test


Components Performance
The evaluation of core quality attributes is not enough to finally decide which
implementation is better or not. The test execution time should be a key
component too. In this chapter, we will examine a library that can help us
measure the performance of our automated tests’ components.

Chapter 10. Test Data Preparation and Configuring Test


Environments
One of the essential parts of each automated test is the test data which we use
in it. It is important that the data is relevant and accessible. In the chapter, we
will discuss how we can create such data through fixtures, APIs, DB layers or
custom tools. Also, we will review how to set up the right way the
environment in which the tests run.

Appendix 1. Defining the Primary Problems that Test


Automation Frameworks Solve
In the first appendix chapter, we will define the problems that the automation
framework is trying to solve. To determine what is needed to deliver high-
quality software, we need to understand what the issues are in the first place.

Appendix 2. Most Exhaustive CSS Selectors Cheat Sheet


A big part of the job of writing maintainable and stable web automation is
related to finding the proper element's selectors. Here will look into a
comprehensive list of CSS selectors.

Appendix 3. Most Exhaustive XPath Selectors Cheat Sheet


The other types of very useful locators are the XPath ones. Knowing them in
detail can help you significantly improve the stability and the readability of
your tests.

Who Is This Book For?


The book is not a getting started guide. If you don't have any prior
programming experience in writing automated tests through WebDriver, this
book won't be very useful to you. I believe it might be invaluable for the
readers that have a couple of years of experience and whose job is to
create/maintain test automation frameworks, or to write high-quality reliable
automated tests.
The book is written in C#. However, I believe that you can use the
approaches and practices in every OOP language. If you have a Java
background, you will get everything you need, don't worry.
Even if you don't get all the concepts from the first read, try to use and
incorporate some of them, later you can return and reread them. I believe
with the accumulation of experience using high-quality practices- you will
become a hard-core test automation ninja!

Before You Get Started


You need to have prior experience in OOP programming language such as
C#, Java, etc. I believe that you can get the book's ideas just from reading the
presented code. However, it is recommended to download and run all of the
solutions on your machine. To do so, clone the book GitHub
repository- https://github.com/AutomateThePlanet/Design-Patterns-for-High-
Quality-Automated-Tests-CSharp-Edition
To be able to build and execute the code, you will need a C# IDE, such as
Visual Studio or Visual Studio Code. Also, you will need to install .NET
Core 3.1+.

Conventions
In this book, you will find several styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and
an explanation of their meaning.
Code words in text are shown as follows: IDialogService
A block of code is set as follows:
[IterationCleanup()]
public void IterationCleanup()
{
BenchmarkCleanup(() =>
{
// execute custom setup code here
});
}

Important words or code snippets are shown in bold.


NOTE

Definition

Reader feedback
Feedback from the readers is always welcome. Let me know what you think
about the book, what you liked or disliked. To do so, email me at
[email protected]

Errata
Although I have taken every care to ensure the accuracy of the content
mistakes do happen. If you find a mistake in the book, whatever in the text or
in the code- I would be grateful if you would report it. If you find any errata,
please email them to [email protected]

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all
media. If you come across any illegal copies of the work, in any form, on the
Internet, please provide me with the location address or website name
immediately so that I can pursue a remedy.
I appreciate your help in protecting the ability to bring you valuable content!

Questions
You can contact me at [email protected] if you are having
any problems with any aspect of the book, and I will do my best to address it.
Also, there is an exclusive forum for the book, where you can create
discussions or ask questions. Feel free to submit the errata there. Navigate
to- https://www.automatetheplanet.com/forums/book-desing-patterns-csharp/
Chapter 1. Defining High-Quality
Test Attributes
This book is not only about teaching you how to use some design patterns or
practices but furthermore to solve particular test automation problems. Some
of them are flaky tests that are hard to maintain, read, or learn to write new
tests, and the list goes on. The goal of the book is to help you write more
stable and faster tests. With the many practices and design patterns presented
in the book, you will be able to write automated tests that need less time to
figure out what went wrong, to be easier to support new requirements, ease
the new team members to learn to use your code and much more.
At the beginning of the chapter, we will go through a short list of the types of
tests. Then, I will define what exactly is a test automation framework and
some other related terms. To be able to write high-quality automated tests,
more knowledge is needed than just knowing how to program in a certain
language or use a specific framework. To solve these problems, our
automated tests should have some core high-quality test attributes. Also, we
will talk about related programming principles abbreviated SOLID.
The following topics will be covered in this chapter:
Different Types of Tests
What Is a Test Automation Framework? Definitions
SOLID Principles
High-Quality Test Attributes

Different Types of Tests


In short, I will define the different types of tests. This will help us understand
where the WebDriver automated tests belong in the development cycle.

Unit Tests
These are, by definition, the smallest test units. This type of test is written to
test an individual object and even individual methods of an object. Unit
testing is highly necessary because it prevents bugs from creeping in at the
lowest level. These tests rarely use any real test data and often solely rely on
generated data.

Integration Tests
They consist of several modules of code put together, allowing them to pass
data between each other. The purpose of these types of tests is to make sure
that all modules integrate and work with each other. They are also known as
component integration tests or integration tests in the small. Usually, in
this kind of testing, we still isolate third-party services such as network, file
system, and OS. Another related term is integration test in the large, which
usually engineers use to mention integration tests that don't isolate 3rd party
dependencies.

System Tests
System Testing is the testing of a complete and fully integrated software
product. It is the highest level of testing. It executes against production
(PROD) or production-like environment, such as staging (STA). Like
integration tests, the system test also tries to verify that all the components,
including third-party services, can communicate well with each other.
These tests can verify our software's functional or non-functional
requirements. Some engineers refer to these tests as End-to-end tests, UI
tests, User Scenario tests. However, I believe there is a slight difference
between the terms.
Our WebDriver automated tests fall into the system testing category. If all
actions and assertions are performed against the user interface (UI), they
should be called UI tests. End-to-end (user scenario) test would be called a
test that is verifying a real User scenario, from the beginning to the end of the
User interaction with the system under test. No shortcuts or mocks are used -
the test mimics human interaction entirely. In the case of system tests, we are
speaking of highly optimized tests that are focusing on verifying a particular
functionality of the system. For example- instead of logging in each time
through the UI or registering new users, we can use internal APIs or DB
directly to do so. The same is valid for the performed assertions. If you use
these low levels, then it is inappropriate to call these types of tests- UI tests.
What Is a Test Automation Framework?
During many conversations at conferences, I realized that many developers
have a wrong conception about what is a test automation framework. Here, I
will try to give you a definition, but before that, we need to go through some
related terms such as what is a software library, a framework, API, test
framework, and others. You need to understand the latter to get what the test
automation framework is.

What Is a Software Library?


Before we can define what a software library is, we need to go over what an
application is.

The first conclusion we can make after this definition is that our automated
tests are also applications. Over the years, there have been many discussions
over the internet and at conferences whether test engineers should be able to
program rather than using UI tools for automated testing. I firmly believe that
the new age test automation QA should be a good programmer, treating
his/her code as production code - following high-quality code standards.
Many engineers believe that in their companies, they have built custom test
frameworks. But in fact, they have libraries or groups of methods and classes
that can help them to write automated tests. The API of the library defines
how the users will access its methods, what arguments they need to pass and
so on. It is a convention of how the library is accessed and used, while the
actual implementation is handled in the library itself. The API is a
specification of what we can use whereas the software library is the actual
implementation of this specification. It should follow the prescribed rules.
We can have multiple implementations of the same API. For example, Java
and Scala implement the Java API. Both are later compiled to bytecode,
which enables Java developers to use the same methods. The same is valid
for the .NET world where C# and VB.NET are different languages, but both
implement the .NET API and compile to MSIL. As .NET developers, we
have the same methods and types in both programming languages.

What Is a Framework?
Software frameworks have these distinctive features that separate
them from libraries:
Inversion of control - the framework controls the flow, and it cannot be
modified as in the case of standard software libraries.
Default behavior - the software framework provides useful default actions.
Extensibility - as a user you can customize and modify some of its actions to
fit your needs which usually cannot be done for software libraries.
Non-modifiable framework code - you can customize or tweak some of the
actions of the framework, but you cannot change its code.
Examples include ASP.NET and .NET for Windows development, Cocoa for
Mac OS X, Cocoa Touch for iOS, and the Android Application Framework
for Android.

As said in the definition, unit testing frameworks help us to write more


quickly tests for verifying the functionality of our methods and classes.
Moreover, we can execute these tests in an automated way so that we don't
need to repeat them manually over and over again. They are usually well
integrated into most popular programming IDEs. We can run our tests from
there plus quickly review the results.
Examples for unit testing frameworks are NUnit, MSTest, JUnit, TestNG.

Test Automation Framework


Now, let’s finally understand what the test automation framework is.
Is Selenium WebDriver a Test Framework?
Many QAs refer to Selenium WebDriver as a test automation framework, but
they cannot be more wrong. Here is the official definition on their website.
“Selenium automates browsers. That's it! What you do with that power is
entirely up to you.”
Primarily, it is for automating web applications for testing purposes, but is
certainly not limited to just that. Boring web-based administration tasks can
(and should!) be automated as well.”
Based on the definition, we can conclude that Selenium WebDriver is
mostly known as the standard for web automation testing, but actually, it is a
tool for controlling browsers that we later use in our software libraries and
frameworks to write automated tests.

SOLID Principles
Before we can define the high-quality test attributes, we should mention
some of the well-known object-oriented programming principles. Throughout
the book I will mention some of them. SOLID is a mnemonic acronym for
five design principles. The goal of these principles is to help us in writing
more understandable, flexible, and maintainable software. SOLID stands for:
SRP – Single Responsibility Principle
OCP – Open/Closed Principle
LSP – Liskov Substitution Principle
ISP – Interface Segregation Principle
DIP – Dependency Inversion Principle
SRP – Single Responsibility Principle

The principles states- "Every software module should have only one reason to
change" which means that every class, method, etc. can do many things, but
they should serve a single purpose.
All the methods and variables in the class should support this purpose.
Everything else should be removed. It shouldn't be like a swiss knife
providing 20 different utility actions since if one of them is changed, all
others need to be updated too.
But if we can have each of those items separated it would be simple, easy to
maintain, and one change will not affect the others. The same principle also
applies to classes and objects in the software architecture- you can have them
as separate simpler classes.
Let me give you an example.
public class CustomerOrder
{
public void Create()
{
try
{
// Database code goes here
}
catch (Exception ex)
{
File.WriteAllText(@"C:\\exception.txt", ex.ToString());
}
}
}

The CustomerOrder class is doing something which it is not supposed to do. It


should create purchases and save them in the database, but if you look at the
catch block closely, you will see that it also does log activity. It has too many
responsibilities.
If we want to follow the Single Responsibility principle SRP, we should
divide the class into two separate simple classes. We can move the logging to
a separate class.
public class FileLogger
{
public void CreateLogEntry(string error)
{
File.WriteAllText(@"C:\\error.txt", error);
}
}

After that the CustomerOrder class can delegate the logging to the FileLogger class
and be more focused on the creating purchases.
public class CustomerOrder
{
private FileLogger _fileLogger = new FileLogger();

public void Create()


{
try
{
// Database code goes here
}
catch (Exception ex)
{
_fileLogger.CreateLogEntry(ex.Message);
}
}
}

OCP – Open/Closed Principle


The principle says that "software entities (classes, modules, functions, etc.)
should be open for extension but closed for modification". It means that, if
new requirements are written for the already implemented functionality, these
can be added in a way so that we don't need to change the whole structure of
the existing code that has been already unit tested. Since if we change it and
add it directly, we can trigger new regression problems.
How about looking at an example?
public enum OrderType
{
Normal,
Silver,
}
public class DiscountCalculator
{
public double CalculateDiscount(OrderType orderType, double totalPrice)
{
if (orderType == OrderType.Silver)
{
return totalPrice - 20;
}
else
{
return totalPrice;
}
}
}

Look at the IF condition in the CalculateDiscount method. The problem is that, if


we add new order types, we will have to add one more IF condition, meaning
that we will have to change the implementation inside the DiscountCalculator
class, because of a change that has happened outside of it. If we need to
change the class every second week, we need to ensure that the previous
requirements are still satisfied, and the new ones integrate well with the old
ones. Instead of modifying the existing code for every new condition, we
strive to develop a solution that can be extensible.
We can easily refactor this code to follow the Open/Closed principle OCP,
so every time a new order type is added, we create a new class, as shown in
the example. The existing code stays untouched, and we need to test and
check only the new cases.
public class DiscountCalculator
{
public virtual double CalculateDiscount(double totalPrice)
{
return totalPrice;
}
}

public class SilverDiscountCalculator : DiscountCalculator


{
public override double CalculateDiscount(double totalPrice)
{
return base.CalculateDiscount(totalPrice) - 20;
}
}

public class GoldDiscountCalculator : DiscountCalculator


{
public override double CalculateDiscount(double totalPrice)
{
return base.CalculateDiscount(totalPrice) - 50;
}
}

LSP – Liskov Substitution Principle


The principle says that "you should be able to use any derived class instead
of a parent class and have it behaved in the same manner without
modification". It means that the child class shouldn't modify or change how
the base class behaves. The main point is that the child classes can be used as
if they are their parent itself, but if you change behavior in a child class,
unexpected issues will occur.
Shall we continue with the same DiscountCalculator example? We want to
introduce a new type of discount for bonus points. To calculate it we will add
a new method to our base class.
public abstract class DiscountCalculator
{
public virtual double CalculateRegularDiscount(double totalPrice)
{
return totalPrice;
}

public virtual double CalculateBonusPointsDiscount(double totalPrice, int points)


{
return totalPrice - points * 0.1;
}
}

As you can see, we have renamed the CalculateDiscount method to


CalculateRegularDiscount and we added a new method for calculating the
discounted total price based on the bonus points.
public class SilverDiscountCalculator : DiscountCalculator
{
public override double CalculateRegularDiscount(double totalPrice)
{
return base.CalculateRegularDiscount(totalPrice) - 20;
}

public override double CalculateBonusPointsDiscount(double totalPrice, int points)


{
return totalPrice - points * 0.5;
}
}
public class GoldDiscountCalculator : DiscountCalculator
{
public override double CalculateRegularDiscount(double totalPrice)
{
return base.CalculateRegularDiscount(totalPrice) - 50;
}

public override double CalculateBonusPointsDiscount(double totalPrice, int points)


{
return totalPrice - points * 1;
}
}
public class PlatinumDiscountCalculator : DiscountCalculator
{
public override double CalculateRegularDiscount(double totalPrice)
{
return base.CalculateRegularDiscount(totalPrice) - 100;
}

public override double CalculateBonusPointsDiscount(double totalPrice, int points)


{
throw new InvalidOperationException("Not applicable for Platinum orders.");
}
}
What we did here is to add a new type of order- Platinum. We have already
applied the maximum allowed discount, so the bonus points discount is not
applicable for Platinum orders. In this case, we decide to throw
InvalidOperationException to let the calling methods know that this operation is not
supported for the Platinum type. As the Polymorphism from the OOP
Principles states, we can use any of the child classes calculators derived from
the DiscountCalculator, as if they are the actual DiscountCalculator class.
Thanks to this principle, as you can see the code below, I have created a
collection of DiscountCalculator objects where I can add Silver, Gold, and
Platinum Discount Calculators as if they are instances of the same type -
DiscountCalculator. After that, I can go through the list using the parent customer
object and invoke the calculation methods.
var _discountCalculators = new List<DiscountCalculator>();
_discountCalculators.Add(new SilverDiscountCalculator());
_discountCalculators.Add(new GoldDiscountCalculator());
_discountCalculators.Add(new PlatinumDiscountCalculator());
foreach (DiscountCalculator discountCalculator in _discountCalculators)
{
double bonusPointsDiscount = discountCalculator.CalculateBonusPointsDiscount(1250);
}

So far so good, but when the CalculateBonusPointsDiscount of the


PlatinumDiscountCalculator is invoked, it leads to InvalidOperationException. The
problem is that the PlatinumDiscountCalculator object looks like a DiscountCalculator,
but the implementation of the child object has changed the expected behavior
of the parent method. So, to follow the Liskov principle, we need to create
two interfaces, one for the regular and other for the bonus points discount.
public interface IRegularDiscountCalculator
{
double CalculateRegularDiscount(double totalPrice);
}

public interface IBonusPointsDiscountCalculator


{
double CalculateBonusPointsDiscount(double totalPrice, int points);
}

I will spare you all the refactoring that we need to do. Let's see how we will
use the code to fix the problem we faced.
var _discountCalculators = new List<IBonusPointsDiscountCalculator>();
_discountCalculators.Add(new SilverDiscountCalculator());
_discountCalculators.Add(new GoldDiscountCalculator());
// _discountCalculators.Add(new PlatinumDiscountCalculator()); // we cannot add it

foreach (IRegularDiscountCalculator discountCalculator in _discountCalculators)


{
double bonusPointsDiscount = discountCalculator.CalculateBonusPointsDiscount(1250);
}

Instead of using the base class, we use the IBonusPointsDiscountCalculator interface.


This means that all added objects to the collection will have this method
implemented otherwise we won't be able to add it to the list.

ISP – Interface Segregation Principle


The principle states that "clients should not be forced to implement interfaces
they don't use. Instead of one fat interface, many small interfaces are
preferred based on groups of methods, each one serving one sub-module".
The Single Responsibility principle can be applied not only for classes but
for the interfaces as well. Each interface should provide methods that serve a
single purpose. In this case the interface gives us functions for more than one
goal, this could lead our implementation code to include methods that are not
needed in the class.
Why not see an example of why we shouldn't use one fat interface? We can
use our previous example for discount calculators. Instead of creating two
separate interfaces we could easily create a single one. To simplify the code,
let’s remove the inheritance.
public interface IDiscountCalculator
{
double CalculateRegularDiscount(double totalPrice);
double CalculateBonusPointsDiscount(double totalPrice, int points);
}

public class GoldDiscountCalculator : IDiscountCalculator


{
public double CalculateRegularDiscount(double totalPrice)
{
return totalPrice - 50;
}

public double CalculateBonusPointsDiscount(double totalPrice, int points)


{
return totalPrice - points * 1;
}
}

public class PlatinumDiscountCalculator : IDiscountCalculator


{
public double CalculateRegularDiscount(double totalPrice)
{
return totalPrice - 100;
}

public double CalculateBonusPointsDiscount(double totalPrice, int points)


{
throw new NotImplementedException("Not applicable for Platinum orders.");
}
}

As you can see, we have a similar problem. Since we have one fat interface,
we are forced to implement all methods- even when we may not need them.
In the future this could become even worse, imagine that we need to add
another type of discount, but this time it is not applicable to the Silver orders.
This would mean that in the SilverDiscountCalculator we will have a new method
that throws NotImplementedException. Better solution would be creating a new
interface rather than updating the current interface.

DIP – Dependency Inversion Principle


The principle states that “high-level classes should not depend on low-level
classes. Both types should be created based on abstractions. These
abstractions shouldn't depend on any low-level details. All details should use
the abstractions instead”. The high-level classes are usually the ones that
contain the business logic, and the low-level ones consist of actions such as
CRUD DB operations, reading files or calling web APIs. When we say that a
class is tightly coupled it means that it has access to low-level details (that it
shouldn't have) instead of using the abstractions.
How about extending our CustomerOrder example a bit? The requirements have
already changed, and we have different types of orders to process- silver,
gold and platinum. Also, there are new requirements which state that we need
to add two more ways of notifications in case something happens. For
example, sending an email and SMS with updates. To do so:
We will create a common interface for all loggers called ILogger.
public interface ILogger
{
void CreateLogEntry(string errorMessage);
}

After that we will create three separate loggers- one for file logging, one for
email and one more for SMS.
public class FileLogger : ILogger
{
public void CreateLogEntry(string errorMessage)
{
File.WriteAllText(@"C:\\exceptions.txt", errorMessage);
}
}

public class EmailLogger : ILogger


{
public void CreateLogEntry(string errorMessage)
{
EmailFactory.SendEmail(errorMessage);
}
}

public class SmsLogger : ILogger


{
public void CreateLogEntry(string errorMessage)
{
SmsFactory.SendSms(errorMessage);
}
}

The business logic behind the new requirements is that we need to send an
email for gold orders and an SMS for platinum orders since they bring our
company more money.
public class CustomerOrder
{
public void Create(OrderType orderType)
{
try
{
// Database code goes here
}
catch (Exception ex)
{
switch (orderType)
{
case OrderType.Platinum:
new SmsLogger().CreateLogEntry(ex.Message);
break;
case OrderType.Gold: new EmailLogger().CreateLogEntry(ex.Message);
break;
default:
new FileLogger().CreateLogEntry(ex.Message);
break;
}
}
}
}

The code violates the Single Responsibility principle again. It should be


focused on creating purchases, but also decides which object to be created,
while it is not the work of the CustomerOrder class to determine which instances
of the ILogger should be used. The biggest problem here is related to the new
keyword. This is an extra responsibility of making the decision which objects
to be created, so if we delegate this responsibility to someone other than the
CustomerOrder class, that will solve the problem.
We can have different child classes of CustomerOrder for the different types of
orders. Also, the logger can be passed as dependency rather than creating it in
the method itself.
public class CustomerOrder
{
private ILogger _logger;

public CustomerOrder(ILogger logger)


{
_logger = logger;
}

public void Create()


{
try
{
// Database code goes here
}
catch (Exception ex)
{
_logger.CreateLogEntry(ex.Message);
}
}
}

public class GoldCustomerOrder : CustomerOrder


{
public GoldCustomerOrder()
: base(new EmailLogger())
{
}
}

public class PlatinumCustomerOrder : CustomerOrder


{
public PlatinumCustomerOrder()
: base(new SmsLogger())
{
}
}

High-Quality Test Attributes


The time has come to define the automated test high-quality attributes. You
will find that some of these attributes are connected to the SOLID principles
and throughout the book, we will continue to talk about these connections.
Since the book is also about design patterns, and we haven't discussed them
yet, we will first go through these definitions, and then we will go briefly
though each of the high-quality attributes. We will not go into many details
now since there will be a dedicated chapter for each of the attributes.

What Is a Design Pattern?


We can define the design patterns as prescribed solutions to everyday
software challenges. They don't consist of code or any specified algorithm,
but instead, they describe how to group your logic smartly, reuse it, or to
make it easier to maintain. It is a template for solving design problems, which
we can use while we create our software solutions.

Test Maintainability and Reusability

Imagine there is a problem in your tests. How much time do you need to
figure out where the problem is? Is it an automation bug or an issue in the
system under test? In the next chapters, we will talk in detail about how to
create maintainable tests using various practices and design patterns. But if at
the beginning, you haven't designed your code in such a way, the changes
may need to be applied to multiple places which can lead to missing some of
them and thus resulting in more bugs. The better the maintainability is, the
easier it is for us to support our existing code, accommodate new
requirements, or just to fix some bugs.
A closely related principle to this definition is the so-called DRY principle-
Don't Repeat Yourself. The most basic idea behind the DRY principle is to
reduce long-term maintenance costs by removing all unnecessary duplication.

Test Readability
By reading the code, you should be able to find out what the code does easily.
A code that is not readable usually requires more time to read, maintain,
understand and can increase the chance to introduce bugs. Some
programmers use huge comments instead of writing more simple readable
code. It is much easier to name your variables, methods, classes correctly,
instead of relying on these comments. Also, as the time goes by, the
comments are rarely updated, and they can mislead the readers.

API Usability
As we mentioned above, the API is the specification of what you can do with
a software library. When we use the term usability together with the term
API, it means "How easy it is for you as a user to find out what the methods
do and how to use them?”. In the case of a Test Library - "How much time a
new user needs to create a new test?"
In the programming community, we sometimes use another term for the same
thing called syntactic sugar. It describes how easy it is to use or read some
expressions. It sweetens the programming languages for humans. The
programming statements become more concise and clearer.

Extensibility
One of the hardest things to develop is to allow these generic frameworks to
be extensible and customizable. The whole point of creating a shared
library is to be used by multiple teams across the company. However, the
different teams work in a different context. So, the library code may not be
working out of the box for them. In order to use your library in all these
various scenarios, that you cannot (and shouldn't) consider while developing
it, the engineers should be able to customize some parts of it to fit their needs.
In the case of automated tests, imagine that you have a test suite testing a
shopping cart. The workflow of the test consists of multiple steps- choosing
the product, changing the quantity, adding more products, applying discount
coupons, filling billing info, providing payment info and so on. If a new
requirement comes - "The billing info should be prefilled for logged users.",
how easy would it be to change the existing tests? Did you write your tests in
a way that, if you add this new functionality, it will not affect the majority of
your existing tests?
You don't need to answer these questions yet. We will discuss them in much
more detail in the next chapters, and I will explain how to build such
solutions.
As you can see this high-quality automated test attribute is closely related to
the SOLID principles we already discussed.

Learning Curve
I also like to call this attribute "Easy Knowledge Transfer". The attribute
answers to the question "How easy is it for someone to learn how to add new
or maintain the existing tests by himself?".
The learning curve is tightly coupled to the API usability, but at the same
time it means something a bit different. If a new member joins your team, is
he able to learn by himself how to use your test automation framework or he
needs to read the documentation if it exists? Or you have a mentoring
program where you need to teach these new members yourself every time
how to use your code? To the end of the book, I will show you how to
develop your test automation code in such a way that the new members will
be able to learn how to use your solution by themselves.

Summary
In this more theoretical first chapter, we went through some essential terms in
automated testing and high-quality programming. We discussed what is a
library, API and how they differ from frameworks. After that, we listed the
different types of tests and defined where our automated tests are situated in
this categorization. Next, I explained with a few examples the different
SOLID principles. At the end of the chapter, you learned what the design
patterns are, and which are the five high-quality test attributes.
In the next chapter, we will create our first automated tests and discuss what
are the most common reasons for them to fail. After that, I will present to you
a couple of best practices and design patterns to make them more stable.
Questions
1. Why is WebDriver not a test framework?
2. What is the difference between integration and system tests?
3. Can we use the term end-to-end test for a test that does not execute exactly a user scenario?
4. How would you refactor a method that does more than one thing?
5. Which principle is not followed if you have copy-pasted multiple times the same code snippet?
6. If your test library is based primarily on static methods, is it extensible?

Further Reading
SOLID Principles made easy - https://hackernoon.com/solid-principles-made-
easy-67b1246bcdf
Inversion of Control Containers and the Dependency Injection pattern-
https://martinfowler.com/articles/injection.html
The Practical Test Pyramid- https://martinfowler.com/articles/practical-test-
pyramid.html
Chapter 2. Optimizing and
Refactoring Legacy Flaky Tests
In this chapter we will create our first automated tests for validating an e-
commerce website. These tests will be a simulation of how similar tests look
as, if they were written by someone who is just starting to use Selenium
WebDriver. I will use them to illustrate some common problems. One by one
we will address those problems in the current chapter and will continue to
improve them to the end of the book with various design patterns and best
practices.
The following topics will be covered in this chapter:
Writing the First Real-World Automated Test
Reasons for Failures
Refactoring Tests
Decorator Design Pattern for Fixing WebDriver Unstable Actions
The Test Independence-Isolation Principle

Writing the First Real-World Automated


Test
As mentioned, we will start by checking the requirements of what we need to
automate. Imagine that you work for a startup called "EU Space Rockets".
Our company makes the world a better place by allowing people to buy
rockets through our website. How cool is that! Your job is to create a series
of automated tests and make sure that everything is working as expected.
Our website uses modern web technologies and all actions are loading
asynchronous instead of reloading the whole page.

First Automated Test Case Explanation


Let us have a look at a step by step approach on how to create your first
automated test case:
1. We navigate to the home page of our website and then click on the 'Add to cart' button that adds a
'Falcon 9' rocket to the cart.
2. Next, we need to click on the 'View cart' button which will lead us to the cart page.

3. If it's our birthday, we can apply the special discount coupon given to us by the company.
4. Before proceeding with any operations, we need to make sure that the loading indicator is not
displayed.

5. Next, since we got a discount, we have additional funding to buy additional rockets. So, we increase
the quantity to 2 and click on the 'Update cart' button.
Discovering Diverse Content Through
Random Scribd Documents
the Italian così così, while sì (not si) is derived from sic, and is analogous
with the affirmative use of the German so and the Yankee jes’ so.

“Oh, how he hast’ned death, burnt to be fryed!” (p. 141.)

The note on fryed is,—


“I. e. freed. Free and freed were sometimes pronounced like fry and
fryed; for Lord North, in his Forest of Varieties, 1645, has these lines:—

’Birds that long have lived free,


Caught and cag’d, but pine and die.’

Here evidently free is intended to rhyme with die.”


“Evidently!” An instance of the unsafeness of rhyme as a guide to
pronunciation. It was die that had the sound of dee, as everybody (but Mr.
Hazlitt) knows. Lovelace himself rhymes die and she on p. 269. But what
shall we say to our editor’s not knowing that fry was used formerly where
we should say burn? Lovers used to fry with love, whereas now they have
got out of the frying-pan into the fire. In this case a martyr is represented as
burning (i. e. longing) to be fried (i. e. burned).

“Her beams ne’er shed or change like th’ hair of day.” (p. 224.)

Mr. Hazlitt’s note is,—


“Hair is here used in what has become quite an obsolete sense. The
meaning is outward form, nature, or character. The word used to be by no
means uncommon; but it is now, as was before remarked, out of fashion;
and indeed I do not think that it is found even in any old writer used exactly
in the way in which Lovelace has employed it.”
We should think not, as Mr. Hazlitt understands it! Did he never hear of
the golden hair of Apollo,—of the intonsum Cynthium? Don Quixote was a
better scholar where he speaks of las doradas hebras de sus hermosos
cabellos. But hair never meant what Mr. Hazlitt says it does, even when
used as he supposes it to be here. It had nothing to do with “outward form,
nature, or character,” but had a meaning much nearer what we express by
temperament, which its color was and is thought to indicate.
On p. 232 “wild ink” is explained to mean “unrefined.” It is a mere
misprint for “vild.”
Page 237, Mr. Hazlitt, explaining an illusion of Lovelace to the “east and
west” in speaking of George Sandys, mentions Sandys’s Oriental travels,
but seems not to know that he translated Ovid in Virginia.
Pages 251, 252:—

“And as that soldier conquest doubted not,


Who but one splinter had of Castriot,
But would assault ev’n death, so strongly charmed,
And naked oppose rocks, with this bone armed.”

Mr. Hazlitt reads his for this in the last verse, and his note on “bone” is:—
“And he found a new jawbone of an ass, and put forth his hand and took
it, and slew a thousand men therewith. (Judges xv. 15.)”
Could the farce of “editing” go further? To make a “splinter of Castriot”
an ass’s jawbone is a little too bad. We refer Mr. Hazlitt to “The Life of
George Castriot, King of Epirus and Albania,” &c., &c., (Edinburgh, 1753,)
p. 32, for an explanation of this profound difficulty. He will there find that
the Turkish soldiers wore relics of Scanderbeg as charms.
Perhaps Mr. Hazlitt’s most astounding note is on the word pickear. (p.
203.)
“So within shot she doth pickear,
Now gall’s [galls] the flank and now the rear.”

“In the sense in which it is here used this word seems to be peculiar to
Lovelace. To pickear, or pickeer, means to skirmish.” And, pray, what other
possible meaning can it have here?
Of his corrections of the press we will correct a few samples.
Page 34, for “Love nee’re his standard,” read “neere.” Page 82, for “fall
too,” read “fall to” (or, as we ought to print such words, “fall-to”). Page 83,
for “star-made firmament,” read “star, made firmament.” Page 161, for “To
look their enemies in their hearse,” read, both for sense and metre, into.
Page 176, for “the gods have kneeled,” read had. Page 182, for “In beds
they tumbled off their own,” read of. Page 184, for “in mine one monument
I lie,” read owne. Page 212, for “Deucalion’s blackflung stone,” read
“backflung.” Of the punctuation we shall give but one specimen, and that a
fair average one:—

“Naso to his Tibullus flung the wreath,


He to Catullus thus did each bequeath.
This glorious circle, to another round,
At last the temples of a god it bound.”

Our readers over ten years of age will easily correct this for themselves.

Time brings to obscure authors[30] an odd kind of reparation, an


immortality, not of love and interest and admiration, but of curiosity merely.
In proportion as their language was uncouth, provincial, or even barbarous,
their value becomes the greater. A book of which only a single copy
escaped its natural enemies, the pastry-cook and trunk-maker, may contain
one word that makes daylight in some dark passage of a great author, and its
name shall accordingly live forever in a note. Is not, then, a scholiastic
athanasy better than none? And if literary vanity survive death, or even
worse, as Brunetto Latini’s made him insensible for a moment to the rain of
fire and the burning sand, the authors of such books as are not properly
literature may still comfort themselves with a non omnis moriar, laying a
mournful emphasis on the adjective, and feeling that they have not lived
wholly in vain while they share with the dodo a fragmentary continuance on
earth. To be sure, the immortality, such as it is, belongs less to themselves
than to the famous men they help to illustrate. If they escape oblivion, it is
by a back door, as it were, and they survive only in fine print at the page’s
foot. At the banquet of fame they sit below the salt. After all, perhaps, the
next best thing to being famous or infamous is to be utterly forgotten, for
this also is to achieve a kind of definite result by living. To hang on the
perilous edge of immortality by the nails, liable at any moment to drop into
the fathomless ooze of oblivion, is at best a questionable beatitude. And yet
sometimes the merest barnacles that have attached themselves to the stately
keels of Dante or Shakespeare or Milton have an interest of their own by
letting us know in what remote waters those hardy navigators went a pearl-
fishing. Has not Mr. Dyce traced Shakespeare’s “dusty death” to Anthony
Copley, and Milton’s “back resounded Death!” to Abraham Fraunce? Nay,
is it not Bernard de Ventadour’s lark that sings forever in the diviner air of
Dante’s Paradise?

“Quan vey laudeta mover


De joi sas alas contra’l rai,
Que s’oblida e s laissa cazer
Per la doussor qu ’al cor li ’n vai.”

“Qual lodoletta che in aere si spazia,


Prima cantando, e poi tace contenta
Dell’ ultima dolcezza che la sazia.”

We are not sure that Bernard’s “Que s’oblida es laissa cazer” is not
sweeter than Dante’s “tace contenta,” but it was plainly the doussor that
gave its cue to the greater poet’s memory, and he has improved on it with
that exquisite ultima, as his master Virgil sometimes did on Homer.
But authors whose interest for us is mainly bibliographic belong rather in
such collections as Mr. Allibone’s. As literature they are oppressive; as
items of literary history they find their place in that vast list which records
not only those named for promotion, but also the killed, wounded, and
missing in the Battle of the Books. There our hearts are touched with
something of the same vague pathos that dims the eye in some deserted
graveyard. The brief span of our earthly immortalities is brought home to us
as nowhere else. What a necrology of notability! How many a
controversialist, terrible in his day, how many a rising genius that somehow
stuck on the horizon, how many a withering satirist, lies here shrunk all
away to the tombstone brevity of a name and date! Think of the aspirations,
the dreams, the hopes, the toil, the confidence (of himself and wife) in an
impartial and generous posterity,—and then read “Smith J. [ohn?] 1713-
1784 (?). The Vision of Immortality, an Epique Poem in twelve books,
1740, 4to. See Lowndes.” The time of his own death less certain than that of
his poem, (which we may fix pretty safely in 1740,) and the only posterity
that took any interest in him the indefatigable compiler to whom a name
was valuable in proportion as it was obscure. Well, to have even so much as
your title-page read after it has rounded the corner of its first century, and to
enjoy a posthumous public of one is better than nothing. This is the true
Valhalla of Mediocrity, the Libro d’oro of the onymi-anonymi, of the never-
named authors who exist only in name. Parson Adams would be here had he
found a printer for his sermons, and Mr. Primrose, if a copy existed of his
tracts on monogamy. Papyrorcetes junior will turn here with justifiable
pride to the name of his respectable progenitor. Here we are secure of
perpetuity at least, if of nothing better, and are sons though we may not be
heirs, of fame. Here is a handy and inexpensive substitute for the waxen
imagines of the Roman patriciate, for those must have been inconvenient to
pack on a change of lodgings, liable to melt in warm weather (even the
elder Brutus himself might soften in the dog-days) and not readily salable
unless to some novus homo willing to buy a set of ancestors ready-made, as
some of our own enthusiasts in genealogy are said to order a family-tree
from the heraldic nurseryman, skilled to imp a slip of Scroggins on a stock
of De Vere or Montmorenci. Fame, it should seem, like electricity, is both
positive and negative, and if a writer must be Somebody to make himself of
permanent interest to the world at large, he must not less be Nobody to have
his namelessness embalmed by M. Guérard. The benignity of Providence is
nowhere more clearly to be seen than in its compensations. As there is a
large class of men madly desirous to decipher cuneiform and other
inscriptions, simply because of their illegibility, so there is another class
driven by a like irresistible instinct to the reprinting of unreadable books.
Whether these have even a philologic value for us depends on the accuracy
and learning bestowed upon them by the editor.
For there is scarcely any rubbish-heap of literature out of which
something precious may not be raked by the diligent explorer, and the late
Mr. Dyce (since Gifford, the best editor of our literature of the Tudor and
Jacobean periods) might well be called the Golden Dustman, so many were
the precious trifles sifted out by his intelligent industry. It would not be easy
to name any work more thoroughly done than his edition of Skelton. He
was not a philologist in the stricter sense, but no man had such a
commonplace-book as he, or knew so exactly the meaning with which
words were used during the period he did so much to illustrate. Elegant
scholar ship is not often, as in him, patient of drudgery and conscientious in
painstaking. Between such a man and Mr. Carew Hazlitt the contrast is by
no means agreeable. The one was not more distinguished by modest
accuracy than the other is by the rash conceit of that half-knowledge which
is more mischievous in an editor than downright ignorance. This language
is strong because it is true, though we should not have felt called upon to
use it but for the vulgar flippancy with which Mr. Hazlitt alludes
depreciatingly to the labors of his predecessors,—to such men as Ritson,
Utterson, Wright, and Sir Frederick Madden, his superiors in everything
that goes to the making of a good editor. Most of them are now dead and
nailed in their chests, and it is not for us to forget the great debt we owe to
them, and others like them, who first opened paths for us through the
tangled wilderness of our early literature. A modern editor, with his ready-
made helps of glossary, annotation, and comment, should think rather of the
difficulties than the defects of these pioneers.
How different is Mr. Hazlitt’s spirit from that of the thorough and
therefore modest scholar! In the Preface to his Altenglische Sprachproben,
Mätzner says of an editor, das Beste was er ist verdankt er Andern, an
accidental pentameter that might seem to have dropped out of Nathan der
Weise. Mr. Hazlitt would profit much by getting some friend to translate for
him the whole paragraph in which it occurs.
We see it announced that Mr. Hazlitt is to superintend a new edition of
Warton’s History of English Poetry, and are pained to think of the treatment
that robust scholar and genial poet is likely to receive at the hands of an
editor without taste, discrimination, or learning. Of his taste a single
specimen may suffice. He tells us that “in an artistic and constructive point
of view, the Mylner of Abington is superior to its predecessor,” that
predecessor being Chaucer’s Reve’s Tale, which, with his usual inaccuracy,
he assigns to the Miller! Of his discrimination we have a sufficient test in
the verses he has fathered upon Herrick in a late edition of the most
graceful of our lyric poets. Perhaps discrimination is not, after all, the right
word, for we have sometimes seen cause to doubt whether Mr. Hazlitt ever
reads carefully the very documents he prints. For example, in the
Biographical Notice prefixed to the Herrick he says (p. xvii): “Mr. W. Perry
Herrick has plausibly suggested that the payments made by Sir William to
his nephew were simply on account of the fortune which belonged to
Robert in right of his father, and which his uncle held in trust; this was
about £400; and I think from allusions in the letters printed elsewhere that
this view may be the correct one.” May be! The poet says expressly, “I
entreat you out of my little possession to deliver to this bearer the
customarye £10, without which I cannot meate [?] my ioyrney.” The words
we have italicized are conclusive. By the way, Mr. Hazlitt’s wise-looking
query after “meate” is conclusive also as to his fitness for editorship. Did he
never hear of the familiar phrase “to meet the expense”? If so trifling a
misspelling can mystify him, what must be the condition of his mind in face
of the more than Protean travesties which words underwent before they
were uniformed by Johnson and Walker? Mr. Hazlitt’s mind, to be sure, like
the wind Cecias, always finds its own fog. In another of Herrick’s letters we
find, “For what her monie can be effected (sic) when there is diuision ’twixt
the hart and hand?” “Her monie” of course means harmonie, and effected is
therefore right. What Mr. Hazlitt may have meant by his “(sic)” it were idle
to inquire.
We have already had occasion to examine some of Mr. Hazlitt’s work,
and we are sorry to say that in the four volumes before us we find no reason
for changing our opinion of his utter disqualification for the duties of
editorship. He seldom clears up a real difficulty (never, we might say, with
lights of his own), he frequently creates a darkness where none was before,
and the peculiar bumptiousness of his incapacity makes it particularly
offensive. We shall bring a few instances in proof of what we assert, our
only embarrassment being in the superabundance of our material. In the
Introduction to the second volume of his collection, Mr. Hazlitt speaks of
“the utter want of common care on the part of previous editors of our old
poetry.” Such oversights as he has remarked upon in his notes are
commonly errors of the press, a point on which Mr. Hazlitt, of all men,
should have been charitable, for his own volumes are full of them. We call
his attention to one such which is rather amusing. In his “additional notes”
we find “line 77, wylle. Strike out the note upon this word; but the
explanation is correct. Be wroght was a misprint, however, for he wroght.”
The error occurs in a citation of three lines in which lother is still left for
tother. The original note affords us so good an example of Mr. Hazlitt’s
style of editing as to be worth preserving. In the “Kyng and the Hermit” we
read,—

“He ne wyst w[h]ere that he was


Ne out of the forest for to passe,
And thus he rode all wylle.”

And here is Mr. Hazlitt’s annotation on the word wylle:—


“i. e. evil. In a MS. of the Tale of the Basyn, supposed by Mr. Wright,
who edited it in 1836, to be written in the Salopian dialect, are the
following lines:—

‘The lother hade litull thoght,


Off husbandry cowth he noght,
But alle his wyves will be wroght.’ ” (Vol. I. p. 16.)

It is plain that he supposed will, in this very simple passage, to mean evil!
This he would seem to rectify, but at the same time takes care to tell us that
“the explanation [of wylle] is correct.” He is willing to give up one blunder,
if only he may have one left to comfort himself withal! Wylle is simply a
rhyming fetch for wild, and the passage means that the king rode at random.
The use of wild with this meaning is still common in such phrases as “he
struck wild.” In “Havelok” we find it in the nearly related sense of being at
a loss, knowing not what to do:—

“To lincolne barfot he yede


Hwan he kam ther he was ful wil,
Ne hauede he no frend to gangen til.”

All wylle, in short, means the kind of editing that is likely to be done by a
gentleman who picks up his misinformation as he goes along. We would
hint that a person must know something before he can use even a glossary
with safety.
In the “King and the Barker,” when the tanner finds out that it is the king
whom he has been treating so familiarly, and falls upon his knees, Mr.
Hazlitt prints,
“He had no meynde of hes hode, nor cape, ne radell,”

and subjoins the following note: “Radell, or raddle, signifies a side of a cart;
but here, apparently, stands for the cart itself. Ritson printed ner adell.” Mr.
Hazlitt’s explanation of raddle, which he got from Halliwell, is incorrect.
The word, as its derivation (from O. F. rastel) implies, means the side or
end of a hay-cart, in which the uprights are set like the teeth of a rake. But
what has a cart to do here? There is perhaps a touch of what an editor of old
doggerel would benignantly call humor, in the tanner’s forgetfulness of his
raiment, but the cart is as little to the purpose as one of Mr. Hazlitt’s own
notes. The tanner was on horseback, as the roads of the period required that
he should be, and good old Ritson was plainly on the right track in his
reading, though his text was muddled by a misprint. As it was, he got one
word right, and so far has the advantage of Mr. Hazlitt. The true reading is,
of course, ner a dell, never a deal, not a whit. The very phrase occurs in
another poem which Mr. Hazlitt has reprinted in his collection,—

“For never a dell


He wyll me love agayne.” (Vol. III. p. 2.)

That adell was a misprint in Ritson is proved by the fact that the word does
not appear in his glossary. If we were to bring Mr. Hazlitt to book for his
misprints! In the poem we have just quoted he gravely prints,—

“Matter in dede,
My sides did blede,”

for “mother, indede,” “through ryght wysenes” for “though ryghtwisenes,”


“with man vnkynde” for “sith man vnkynde,” “ye knowe a parte” for “ye
knowe aperte,” “here in” for “herein,” all of which make nonsense, and all
come within the first one hundred and fifty lines, and those of the shortest,
mostly of four syllables each. Perhaps they rather prove ignorance than
want of care. One blunder falling within the same limits we have reserved
for special comment, because it affords a good example of Mr. Hazlitt’s
style of editing:—
“Your herte souerayne
Clouen in twayne
By longes the blynde.” (Vol. III. p. 7.)

Here the uninstructed reader would be as completely in the dark as to what


longes meant as the editor plainly was himself. The old rhymer no doubt
wrote Longis, meaning thereby Longinus, a personage familiar enough, one
should think, to any reader of mediæval poetry. Mr. Hazlitt absolves himself
for not having supplied a glossary by the plea that none is needed by the
class of readers for whom his volumes are intended. But this will hardly
seem a valid excuse for a gentleman who often goes out of his way to
explain in his notes such simple matters as that “shape” means “form,” and
that “Johan of the golden mouthe” means “St. Chrysostom,” which, indeed,
it does not, any more than Johannes Baptista means St. Baptist. We will
supply Mr. Hazlitt with an illustration of the passage from Bekker’s
Ferabras, the more willingly as it may direct his attention to a shining
example of how an old poem should be edited:—

“en la crotz vos pendero li fals Iuzieu truan,


can Longis vos ferie de sa lansa trencan:
el non avia vist en trastot son vivan;
lo sanc li venc per l’asta entro al punh colan;
e [el] toquet ne sos huelhs si vic el mantenan.”

Mr. Hazlitt, to be sure (who prints sang parlez for sanz parler) (Vol. I. p.
265), will not be able to form any notion of what these verses mean, but
perhaps he will be able to draw an inference from the capital L that longes
is a proper name. The word truan at the end of the first verse of our citation
may also suggest to him that truant is not quite so satisfactory an
explanation of the word trewāt as he seems to think. (Vol. IV. p. 24, note.)
In deference to Mr. Hazlitt’s presumed familiarity with an author sometimes
quoted by him in his notes, we will point him to another illustration:—

“Ac ther cam forth a knyght,


With a kene spere y-grounde
Highte Longeus, as the lettre telleth,
And longe hadde lore his sighte.”
Piers Ploughman, Wright, p. 374.

Mr. Hazlitt shows to peculiar advantage where old French is in question.


Upon the word Osyll he favors us with the following note: “The blackbird.
In East Cornwall ozell is used to signify the windpipe, and thence the bird
may have had its name, as Mr. Couch has suggested to me.” (Vol. II. p. 25.)
Of course the blackbird, alone among fowls, is distinguished by a windpipe!
The name is merely another form of O. F. oisil, and was usurped naturally
enough by one of the commonest birds, just as pajaro (L. passer) in
Spanish, by a similar process in the opposite direction, came to mean bird in
general. On the very next page he speaks of “the Romance which is
vulgarly entitled Lybeaus Disconus, i. e. Le Beau Disconnu.” If he had
corrected Disconus to Desconus, all had been well; but Disconnu neither is
nor ever was French at all. Where there is blundering to be done, one stone
often serves Mr. Hazlitt for two birds. Ly beaus Disconus is perfectly
correct old French, and another form of the adjective (bius) perhaps
explains the sound we give to the first syllable of beauty and Beaufort. A
barrister at law, as Mr. Hazlitt is, may not be called on to know anything
about old English or modern French, but we might fairly expect him to have
at least a smattering of Law French! In volume fourth, page 129, a goodman
trying his wife,

“Bad her take the pot that sod ouer the fire
And set it abooue vpon the astire.”

Mr. Hazlitt’s note upon astire is “hearth, i. q. astre.” Knowing that the
modern French was âtre, he too rashly inferred a form which never existed
except in Italian. The old French word is aistre or estre, but Mr. Hazlitt, as
usual, prefers something that is neither old French nor new. We do not
pretend to know what astire means, but a hearth that should be abooue the
pot seething over the fire would be unusual, to say the least, in our semi-
civilized country.
In the “Lyfe of Roberte the Deuill” (Vol. I. p. 232), Mr. Hazlitt twice
makes a knight sentre his lance, and tells us in a note that the “Ed. 1798 has
fentered,” a very easy misprint for the right word feutered. What Mr. Hazlitt
supposed to be the meaning of sentre he has not vouchsafed to tell us.
Fautre (sometimes faltre or feutre) means in old French the rest of a lance.
Thus in the Roman du Renart (26517),

“Et mist sa lance sor le fautre.”

But it also meant a peculiar kind of rest. In Sir F. Madden’s edition of


Gawayne (to which Mr. Hazlitt refers occasionally) we read,

“They feutred their lances, these knyghtes good”;

and in the same editor’s “William and the Werwolf,”

“With sper festened in feuter, him for to spille.”

In a note on the latter passage Sir F. Madden says, “There seems no reason,
however, why it [feuter] should not mean the rest attached to the armour.”
But Roquefort was certainly right in calling it a “garniture d’une selle pour
tenir la lance.” A spear fastened to the saddle gave more deadly weight to
the blow. The “him for to spille” implies this. So in “Merlin” (E. E. Text
Soc., p. 488): “Than thei toke speres grete and rude, and putte hem in
fewtre, and that is the grettest crewelte that oon may do, ffor turnement
oweth to be with-oute felonye, and they meved to smyte hem as in mortall
werre.” The context shows that the fewtre turned sport into earnest. A
citation in Raynouard’s Lexique Roman (though wrongly explained by him)
directed us to a passage which proves that this particular kind of rest for the
lance was attached to the saddle, in order to render the blow heavier:—

“Lances à [lege as] arçons afeutrées


Pour plus de dures colées rendre.”
Branche des Royaux Lignages, 4514, 4515.

Mr. Hazlitt, as we have said, lets no occasion slip to insinuate the


inaccuracy and carelessness of his predecessors. The long and useful career
of Mr. Wright, who, if he had given us nothing more than his excellent
edition of “Piers Ploughman” and the volume of “Ancient Vocabularies,”
would have deserved the gratitude of all lovers of our literature or students
of our language, does not save him from the severe justice of Mr. Hazlitt,
nor is the name of Warton too venerable to be coupled with a derogatory
innuendo. Mr. Wright needs no plea in abatement from us, and a mischance
of Mr. Hazlitt’s own has comically avenged Warton. The word prayer, it
seems, had somehow substituted itself for prayse in a citation by Warton of
the title of the “Schole-House of Women.” Mr. Hazlitt thereupon takes
occasion to charge him with often “speaking at random,” and after
suggesting that it might have been the blunder of a copyist, adds, “or it is by
no means impossible that Warton himself, having been allowed to inspect
the production, was guilty of this oversight.” (Vol. IV. p. 98.) Now, on the
three hundred and eighteenth page of the same volume, Mr. Hazlitt has
allowed the following couplet to escape his conscientious attention:—

“Next, that no gallant should not ought suppose


That prayers and glory doth consist in cloathes.”

Lege, nostro periculo, PRAYSE! Were dear old Tom still on earth, he might
light his pipe cheerfully with any one of Mr. Hazlitt’s pages, secure that in
so doing he was consuming a brace of blunders at the least. The word
prayer is an unlucky one for Mr. Hazlitt. In the “Knyght and his Wyfe”
(Vol. II. p. 18) he prints:—

“And sayd, Syre, I rede we make


In this chapel oure prayers,
That God us kepe both in ferrus.”

Why did not Mr. Hazlitt, who explains so many things that everybody
knows, give us a note upon in ferrus? It would have matched his admirable
elucidation of waygose, which we shall notice presently. Is it not barely
possible that the MS. may have read prayere and in fere? Prayere occurs
two verses further on, and not as a rhyme.
Mr. Hazlitt even sets Sir Frederick Madden right on a question of Old
English grammar, telling him superciliously that can, with an infinitive, in
such phrases as he can go, is used not “to denote a past tense, but an
imperfect tense.” By past we suppose him to mean perfect. But even if an
imperfect tense were not a past one, we can show by a passage in one of the
poems in this very collection that can, in the phrases referred to, sometimes
not only denotes a past but a perfect tense:—

“And thorow that worde y felle in pryde;


As the aungelle can of hevyn glyde,
And with the tywnkling[31] of an eye
God for-dud alle that maystrye
And so hath he done for my gylte.”

Now the angel here is Lucifer, and can of hevyn glyde means simply fell
from heaven, not was falling. It is in the same tense as for-dud in the next
line. The fall of the angels is surely a fait accompli. In the last line, by the
way, Mr. Hazlitt changes “my for” to “for my,” and wrongly, the my
agreeing with maystrye understood. In modern English we should use mine
in the same way. But Sir Frederick Madden can take care of himself.
We have less patience with Mr. Hazlitt’s impertinence to Ritson, a man
of ample reading and excellent taste in selection, and who, real scholar as
he was, always drew from original sources. We have a foible for Ritson with
his oddities of spelling, his acerb humor, his unconsciously depreciatory
mister Tyrwhitts and mister Bryants, and his obstinate disbelief in Doctor
Percy’s folio manuscript. Above all, he was a most conscientious editor, and
an accurate one so far as was possible with the lights of that day. Mr. Hazlitt
has reprinted two poems, “The Squyr of Low Degre” and “The Knight of
Curtesy,” which had already been edited by Ritson. The former of these has
passages that are unsurpassed in simple beauty by anything in our earlier
poetry. The author of it was a good versifier, and Ritson, though he
corrected some glaring errors, did not deal so trenchantly with verses
manifestly lamed by the copyist as perhaps an editor should.[32] Mr. Hazlitt
says of Ritson’s text, that “it offers more than an hundred departures from
the original,” and of the “Knight of Courtesy,” that “Ritson’s text is by no
means accurate.” Now Mr. Hazlitt has adopted nearly all of Ritson’s
emendations, without giving the least hint of it. On the contrary, in some
five or six instances, he gives the original reading in a foot-note with an
“old ed. has” so and so, thus leaving the reader to infer that the corrections
were his own. Where he has not followed Ritson, he has almost uniformly
blundered, and that through sheer ignorance. For example, he prints,

“Alas! it tourned to wroth her heyle,”

where Ritson had substituted wrotherheyle. The measure shows that Ritson
was right. Wroth her heyle, moreover, is nonsense. It should have been
wrother her heyle at any rate, but the text is far too modern to admit of that
archaic form. In the “Debate of the Body and the Soul” (Mätzner’s A. E.
Sprachproben, 103) we have,

“Why schope thou me to wrother-hele,”

and in “Dame Siris” (Ibid., 110),


“To goder hele ever came thou hider.”

Mr. Hazlitt prints,

“For yf it may be found in thee


That thou them [de] fame for enuyte.”

The emendation [de] is Ritson’s, and is probably right, though it would


require, for the metre’s sake, the elision of that at the beginning of the
verse. But what is enuyte? Ritson reads enmyte, which is, of course, the true
reading. Mr. Hazlitt prints (as usual either without apprehending or without
regarding the sense),

“With browes bent and eyes full mery,”

where Ritson has brent, and gives parallel passages in his note on the word.
Mr. Hazlitt gives us

“To here the bugles there yblow,


With their bugles in that place,”

though Ritson had made the proper correction to begles. Mr. Hazlitt, with
ludicrous nonchalance, allows the Squire to press into the throng
“With a bastard large and longe,”

and that with the right word (baslarde) staring him in the face from Ritson’s
text. We wonder he did not give us an illustrative quotation from
Falconbridge! Both editors have allowed some gross errors to escape, such
as “come not” for “come” (v. 425); “so leue he be” for “ye be” (v. 593);
“vnto her chambre” for “vnto your” (v. 993); but in general Ritson’s is the
better and more intelligent text of the two. In the “Knight of Curtesy,” Mr.
Hazlitt has followed Ritson’s text almost literatim. Indeed, it is
demonstrable that he gave it to his printers as copy to set up from. The
proof is this: Ritson has accented a few words ending in tè. Generally he
uses the grave accent, but now and then the acute. Mr. Hazlitt’s text follows
all these variations exactly. The main difference between the two is that
Ritson prints the first personal pronoun i, and Mr. Hazlitt, I. Ritson is
probably right; for in the “Scholehouse of Women” (vv. 537, 538) where the
text no doubt was

“i [i. e. one] deuil a woman to speak may constrain,


But all that in hel be cannot let it again,”

Mr. Hazlitt changes “i” to “A,” and says in a note, “Old ed. has I.” That by
his correction he should miss the point was only natural; for he evidently
conceives that the sense of a passage does not in the least concern an editor.
An instance or two will suffice. In the “Knyght and his Wyfe” (Vol. II. p.
17) we read,

“The fynd tyl hure hade myche tene


As hit was a sterfull we seme!”

Mr. Hazlitt in a note explains tene to mean “trouble or sorrow”; but if that
were its meaning here, we should read made, and not hade, which would
give to the word its other sense of attention. The last verse of the couplet
Mr. Hazlitt seems to think perfectly intelligible as it stands. We should not
be surprised to learn that he looked upon it as the one gem that gave lustre
to a poem otherwise of the dreariest. We fear we shall rob it of all its charm
for him by putting it into modern English:—

“As it was after full well seen.”

So in the “Smyth and his Dame” (Vol. III. p. 204) we read,

“It were a lytele maystry


To make a blynde man to se,”

instead of “as lytell.” It might, indeed, be as easy to perform the miracle on


a blind man as on Mr. Hazlitt. Again, in the same poem, a little further on,

“For I tell the now trevely,


Is none so wyse ne to sle,
But ever ye may som what lere,”

which, of course, should be,

“ne so sle
But ever he may som what lere.”

Worse than all, Mr. Hazlitt tells us (Vol. I. p. 158) that when they bury the
great Khan, they lay his body in a tabernacle,
“With sheld and spere and other wede
With a whit mere to gyf him in ylke.”
We will let Sir John Maundeville correct the last verse: “And they seyn that
when he shale come into another World ... the mare schalle gheven him
mylk.” Mr. Hazlitt gives us some wretched doggerel by “Piers of Fulham,”
and gives it swarming with blunders. We take at random a couple of
specimens:—

“And loveship goith ay to warke


Where that presence is put a bake,” (Vol. II. pp. 13, 14,)

where we should read “love’s ship,” “wrake,” and “abake.” Again, just
below,

“Ffor men haue seyn here to foryn,


That love laughet when men be forsworn.”

Love should be “Iove.” Ovid is the obscure person alluded to in the “men
here to foryn”:

“Jupiter e cœlo perjuria ridet amantum.”

We dare say Mr. Hazlitt, if he ever read the passage, took it for granted that
“to foryn” meant too foreign, and gave it up in despair. But surely
Shakespeare’s

“At lovers’ perjuries,


They say, Jove laughs,”

is not too foreign to have put him on the right scent.


Mr. Hazlitt is so particular in giving us v for u and vice versa, that such
oversights are a little annoying. Every man his own editor seems to be his
theory of the way in which old poetry should be reprinted. On this plan, the
more riddles you leave (or make) for the reader to solve, the more pleasure
you give him. To correct the blunders in any book edited by Mr. Hazlitt
would give the young student a pretty thorough training in archaic English.
In this sense the volumes before us might be safely recommended to
colleges and schools. When Mr. Hazlitt undertakes to correct, he is pretty
sure to go wrong. For example, in “Doctour Doubble Ale” (Vol. III. p. 309)
he amends thus:—
“And sometyme mikle strife is
Among the ale wyfes, [y-wis];

where the original is right as it stands. Just before, in the same poem, we
have a parallel instance:—

“And doctours dulpatis


That falsely to them pratis,
And bring them to the gates.”

The original probably reads (or should read) wyfis and gatis. But it is too
much to expect of Mr. Hazlitt that he should remember the very poems he is
editing from one page to another, nay, as we shall presently show, that he
should even read them. He will change be into ben where he should have let
it alone (though his own volumes might have furnished him with such
examples as “were go,” “have se,” “is do,” and fifty more), but he will
sternly retain bene where the rhyme requires be, and Ritson had so printed.
In “Adam Bel” the word pryme occurs (Vol. II. p. 140), and he vouchsafes
us the following note: “i. e. noon. It is commonly used by early writers in
this sense. In the Four P. P., by John Heywood, circa 1540, the apothecary
says
‘If he taste this boxe nye aboute the pryme
By the masse, he is in heven or even songe tyme.’ ”

Let our readers admire with us the easy “it is commonly used” of Mr.
Hazlitt, as if he had store of other examples in his note-book. He could an if
he would! But unhappily he borrowed this single quotation from Nares,
and, as usual, it throws no scintilla of light upon the point in question, for
his habit in annotation is to find by means of a glossary some passage (or
passages if possible) in which the word to be explained occurs, and then—
why, then to give the word as an explanation of itself. But in this instance,
Mr. Hazlitt, by the time he had reached the middle of his next volume (Vol.
III. p. 281) had wholly forgotten that pryme was “commonly used by early
writers” for noon, and in a note on the following passage,
“I know not whates a clocke
But by the countre cocke,
The mone nor yet the pryme,
Vntyll the sonne do shyne,”

he informs us that it means “six o’clock in the morning”! Here again this
editor, who taxes Ritson with want of care, prints mone for none in the very
verse he is annotating, and which we may therefore presume that he had
read. A man who did not know the moon till the sun showed it him is a
match even for Mr. Hazlitt himself. We wish it were as easy as he seems to
think it to settle exactly what pryme means when used by our “early
writers,” but it is at least absolutely certain that it did not mean noon.
But Mr. Hazlitt, if these volumes are competent witnesses, knows
nothing whatever about English, old or new. In the “Mery Jest of Dane
Hew” he finds the following verses,

“Dame he said what shall we now doo


Sir she said so mote go
The munk in a corner ye shall lay”

which we print purposely without punctuation. Mr. Hazlitt prints them thus,

“Dame, he said, what shall we now doo?


Sir, she said, so mote [it] go.
The munk,” &c.,

and gives us a note on the locution he has invented to this effect, “? so


might it be managed.” And the Chancellor said, I doubt! Mr. Hazlitt’s query
makes such a singular exception to his more natural mood of immediate
inspiration that it is almost pathetic. The amended verse, as everybody (not
confused by too great familiarity with our “early writers”) knows, should
read,

“Sir, she said, so might I go,”

and should be followed only by a comma, to show its connection with the
next. The phrase “so mote I go,” is as common as a weed in the works of
the elder poets, both French and English; it occurs several times in Mr.
Hazlitt’s own collection, and its other form, “so mote I fare,” which may
also be found there, explains its meaning. On the phrase point-device (Vol.
III. p. 117) Mr. Hazlitt has a positively incredible note, of which we copy
only a part: “This term, which is commonly used in early poems” [mark
once more his intimacy with our earlier literature] “to signify extreme
exactitude, originated in the points which were marked on the astrolabe, as
one of the means which the astrologers and dabblers in the black art
adopted to enable them (as they pretended) to read the fortunes of those by
whom they were consulted in the stars and planetary orbs. The excessive
precision which was held to be requisite in the delineation of these points”
[the delineation of a point is good!] “&c. on the astrolabe, led to point-
device, or points-device (as it is sometimes found spelled), being used as a
proverbial expression for minute accuracy of any kind.” Then follows a
quotation from Gower, in which an astrolabe is spoken of “with points and
cercles merveilous,” and the note proceeds thus: “Shakespeare makes use of
a similar figure of speech in the Tempest, I. 2, where the following dialogue
takes place between Prospero and Ariel:—

‘Prosp. Hast thou, spirit,


Performed to point the tempest that I bade thee?
Ar. In every article.’ ”

Neither the proposed etymology nor the illustration requires any remark
from us. We will only say that point-device is excellently explained and
illustrated by Wedgwood.
We will give a few more examples out of many to show Mr. Hazlitt’s
utter unfitness for the task he has undertaken. In the “Kyng and the
Hermyt” are the following verses,

“A wyld wey, I hold, it were


The wey to wend, I you swere,
Bot ye the dey may se,”

meaning simply, “I think it would he a wild thing (in you) to go on your


way unless you wait for daylight.” Mr. Hazlitt punctuates and amends thus:

“A wyld wey I hold it were,
The wey to wend, I you swere,
Ye bot [by] the dey may se.” (Vol. I. p. 19.)

The word bot seems a stumbling-block to Mr. Hazlitt. On page 54 of the


same volume we have,

“Herd i neuere bi no leuedi


Hote hendinesse and curteysi.”

The use of the word by as in this passage would seem familiar enough, and
yet in the “Hye Way to the Spittel Hous” Mr. Hazlitt explains it as meaning
be. Any boy knows that without sometimes means unless (Fielding uses it
often in that sense), but Mr. Hazlitt seems unaware of the fact. In his first
volume (p. 224) he gravely prints:—
“They trowed verelye that she shoulde dye;
With that our ladye wold her helpe and spede.”

The semicolon after dye shows that this is not a misprint, but that the editor
saw no connection between the first verse and the second. In the same
volume (p. 133) we have the verse,

“He was a grete tenement man, and ryche of londe and lede,”

and to lede Mr. Hazlitt appends this note: “Lede, in early English, is found
in various significations, but here stands as the plural of lad, a servant.” In
what conceivable sense is it the plural of lad? And does lad necessarily
mean a servant? The Promptorium has ladde glossed by garcio, but the
meaning servant, as in the parallel cases of παις, puer, garçon, and boy, was
a derivative one, and of later origin. The word means simply man (in the
generic sense) and in the plural people. So in the “Squyr of Low Degre,”

“I will forsake both land and lede,”

and in the “Smyth and his Dame,”


“That hath both land and lyth.”
The word was not “used in various significations.” Even so lately as
“Flodden Ffeild” we find,

“He was a noble leed of high degree.”

Connected with land it was a commonplace in German as well as in


English. So in the Tristan of Godfrey of Strasburg,

“Er Bevalch sin liut und fin lant


An sines marschalkes hant.”

Mr. Hazlitt is more nearly right than usual when he says that in the
particular case cited above lede means servants. But were these of only one
sex? Does he not know that even in the middle of the last century when an
English nobleman spoke of “my people,” he meant simply his domestics?
Encountering the familiar phrase No do! (Vol. IV. p. 64), Mr. Hazlitt
changes it to Not do! He informs us that Goddes are (Vol. I. p. 197) means
“God’s heir”! He says (Vol. II. p. 146): “To borrow, in the sense of to take,
to guard, or to protect, is so common in early English that it is unnecessary
to bring forward any illustration of its use in this way.” But he relents, and
presently gives us two from Ralph Roister Doister, each containing the
phrase “Saint George to borrow!” That borrow means take no owner of
books need be told, and Mr. Hazlitt has shown great skill in borrowing
other people’s illustrations for his notes, but the phrase he quotes has no
such meaning as he gives it. Mr. Dyce in a note on Skelton explains it
rightly, “St. George being my pledge or surety.”
We gather a few more of these flowers of exposition and etymology:—
“The while thou sittest in chirche, thi bedys schalt thou bidde.”
(Vol. I. p. 181.)

i. e. thou shalt offer thy prayers. Mr. Hazlitt’s note on bidde is, “i. e. bead.
So in The Kyng and the Hermit, line 111:—

‘That herd an hermyte there within


Unto the gate he gan to wyn
Bedying his prayer.’ ”
Precisely what Mr. Hazlitt understands by beading (or indeed by anything
else) we shall not presume to divine, but we should like to hear him
translate “if any man bidde the worshyp,” which comes a few lines further
on. Now let us turn to page 191 of the same volume. “Maydenys ben
loneliche and no thing sekir.” Mr. Hazlitt tells us in a note that “sekir or
sicker” is a very common form of secure, and quotes in illustration from the
prose Morte Arthure, “A! said Sir Launcelot, comfort yourselfe, for it shall
bee unto us as a great honour, and much more then if we died in any other
places: for of death wee be sicker.” Now in the text the word means safe,
and in the note it means sure. Indeed sure, which is only a shorter form of
secure, is its ordinary meaning. “I mak sicker,” said Kirkpatrick, a not
unfitting motto for certain editors, if they explained it in their usual
phonetic way.
In the “Frere and the Boye,” when the old man has given the boy a bow,
he says:—

“Shote therin, whan thou good thynke;


For yf thou shote and wynke,
The prycke thow shalte hytte.”

Mr. Hazlitt’s explanation of wynke is “to close one eye in taking aim,” and
he quotes a passage from Gascoigne in support of it. Whatever Gascoigne
meant by the word (which is very doubtful), it means nothing of the kind
here, and is another proof that Mr. Hazlitt does not think it so important to
understand what he reads as St. Philip did. What the old man said was,
“even if you shut both your eyes, you can’t help hitting the mark.” So in
“Piers Ploughman” (Whitaker’s text),

“Wynkyng, as it were, wytterly ich saw hyt.”

Again, for our editor’s blunders are as endless as the heads of an old-
fashioned sermon, in the “Schole-House of Women” (Vol. IV. p. 130), Mr.
Hazlitt has a note on the phrase “make it nice,”
(“And yet alwaies they bible bable
Of euery matter and make it nice,”)
which reads thus: “To make it pleasant or snug. I do not remember to have
seen the word used in this sense very frequently. But Gascoigne has it in a
precisely similar way:—

‘The glosse of gorgeous Courtes by thee did please mine eye,


A stately sight me thought it was to see the braue go by,
To see their feathers flaunte, to make [marke!] their straunge deuise,
To lie along in ladies lappes, to lispe, and make it nice.’ ”

To make it nice means nothing more nor less than to play the fool, or rather,
to make a fool of yourself, faire le niais. In old English the French niais and
nice, from similarity of form and analogy of meaning, naturally fused
together in the word nice, which, by an unusual luck, has been promoted
from a derogatory to a respectful sense. Gascoigne’s lispe might have put
Mr. Hazlitt on his guard, if he ever considered the sense of what he quotes.
But he never does, nor of what he edits either. For example, in the “Smyth
and his Dame” we find the following note: “Prowe, or proffe, is not at all
uncommon as a form of profit. In the ‘Seven Names of a Prison,’ a poem
printed in Reliquiæ Antiquæ, we have,—

‘Quintum nomen istius foveæ ita probatum,


A place of proff for man to know bothe frend and foo.’ ”

Now proff and prow are radically different words. Proff here means proof,
and if Mr. Hazlitt had read the stanza which he quotes, he would have found
(as in all the others of the same poem) the meaning repeated in Latin in the
last line, probacio amicorum.
But we wish to leave our readers (if not Mr. Hazlitt) in good humor, and
accordingly we have reserved two of his notes as bonnes bouches. In
“Adam Bel,” when the outlaws ask pardon of the king,
“They kneled downe without lettyng
And each helde vp his hande.”

To this passage (tolerably plain to those not too familiar with “our early
literature”) Mr. Hazlitt appends this solemn note: ‘To hold up the hand was
formerly a sign of respect or concurrence, or a mode of taking an oath; and
thirdly as a signal for mercy. In all these senses it has been employed from
the most ancient times; nor is it yet out of practice, as many savage nations
still testify their respect to a superior by holding their hand [either their
hands or the hand, Mr. Hazlitt!] over their head. Touching the hat appears to
be a vestige of the same custom. In the present passage the three outlaws
may be understood to kneel on approaching the throne, and to hold up each
a hand as a token that they desire to ask the royal clemency or favour. In the
lines which are subjoined it [what?] implies a solemn assent to an oath:

‘This swore the duke and all his men,


And all the lordes that with him lend,
And tharto to[33] held they up thaire hand.’ ”
Minot’s Poems, ed. 1825, p. 9.

The admirable Tupper could not have done better than this, even so far as
the mere English of it is concerned. Where all is so fine, we hesitate to
declare a preference, but, on the whole, must give in to the passage about
touching the hat, which is as good as “mobbled queen.” The Americans are
still among the “savage nations” who “imply a solemn assent to an oath” by
holding up the hand. Mr. Hazlitt does not seem to know that the question
whether to kiss the book or hold up the hand was once a serious one in
English politics.
But Mr. Hazlitt can do better even than this! Our readers may be
incredulous; but we shall proceed to show that he can. In the “Schole-House
of Women,” among much other equally delicate satire of the other sex (if
we may venture still to call them so), the satirist undertakes to prove that
woman was made, not of the rib of a man, but of a dog:—

‘And yet the rib, as I suppose,


That God did take out of the man
A dog vp caught, and a way gose
Eat it clene; so that as than
The woork to finish that God began
Could not be, as we haue said,
Because the dog the rib connaid.
A remedy God found as yet;
Out of the dog he took a rib.”

Mr. Hazlitt has a long note on way gose, of which the first sentence shall
suffice us: “The origin of the term way-goose is involved in some
obscurity.” We should think so, to be sure! Let us modernize the spelling
and grammar, and correct the punctuation, and then see how it looks:—

“A dog up caught and away goes,


Eats it up.”

We will ask Mr. Hazlitt to compare the text, as he prints it, with

“Into the hall he gose.” (Vol. III. p. 67.)

We should have expected a note here on the “hall he-goose.” Not to speak
of the point of the joke, such as it is, a goose that could eat up a man’s rib
could only be matched by one that could swallow such a note,—or write it!
We have made but a small florilegium from Mr. Hazlitt’s remarkable
volumes. His editorial method seems to have been to print as the Lord
would, till his eye was caught by some word he did not understand, and
then to make the reader comfortable by a note showing that the editor is as
much in the dark as he. We are profoundly thankful for the omission of a
glossary. It would have been a nursery and seminary of blunder. To expose
pretentious charlatanry is sometimes the unpleasant duty of a reviewer. It is
a duty we never seek, and should not have assumed in this case but for the
impertinence with which Mr. Hazlitt has treated dead and living scholars,
the latchets of whose shoes he is not worthy to unloose, and to express their
gratitude to whom is, or ought to be, a pleasure to all honest lovers of their
mother-tongue. If he who has most to learn be the happiest man, Mr. Hazlitt
is indeed to be envied; but we hope he will learn a great deal before he lays
his prentice hands on Warton’s “History of English Poetry,” a classic in its
own way. If he does not learn before, he will be likely to learn after, and in
no agreeable fashion.
EMERSON THE LECTURER.

I T is a singular fact, that Mr. Emerson is the most steadily attractive


lecturer in America. Into that somewhat cold-waterish region adventurers
of the sensational kind come down now and then with a splash, to become
disregarded King Logs before the next season. But Mr. Emerson always
draws. A lecturer now for something like a third of a century, one of the
pioneers of the lecturing system, the charm of his voice, his manner, and his
matter has never lost its power over his earlier hearers, and continually
winds new ones in its enchanting meshes. What they do not fully
understand they take on trust, and listen, saying to themselves, as the old
poet of Sir Philip Sidney,—
“A sweet, attractive, kind of grace,
A full assurance given by looks,
Continual comfort in a face,
The lineaments of gospel books.”

We call it a singular fact, because we Yankees are thought to be fond of


the spread-eagle style, and nothing can be more remote from that than his.
We are reckoned a practical folk, who would rather hear about a new air-
tight stove than about Plato; yet our favorite teacher’s practicality is not in
the least of the Poor Richard variety. If he have any Buncombe
constituency, it is that unrealized commonwealth of philosophers which
Plotinus proposed to establish; and if he were to make an almanac, his
directions to farmers would be something like this: “October: Indian
Summer; now is the time to get in your early Vedas.” What, then, is his
secret? Is it not that he out-Yankees us all? that his range includes us all?
that he is equally at home with the potato-disease and original sin, with
pegging shoes and the Over-soul? that, as we try all trades, so has he tried
all cultures? and above all, that his mysticism gives us a counterpoise to our
super-practicality?
There is no man living to whom, as a writer, so many of us feel and
thankfully acknowledge so great an indebtedness for ennobling impulses,—
none whom so many cannot abide. What does he mean? ask these last.
Where is his system? What is the use of it all? What the deuse have we to
do with Brahma? I do not propose to write an essay on Emerson at this
time. I will only say that one may find grandeur and consolation in a starlit
night without caring to ask what it means, save grandeur and consolation;
one may like Montaigne, as some ten generations before us have done,
without thinking him so systematic as some more eminently tedious (or
shall we say tediously eminent?) authors; one may think roses as good in
their way as cabbages, though the latter would make a better show in the
witness-box, if cross-examined as to their usefulness; and as for Brahma,
why, he can take care of himself, and won’t bite us at any rate.
The bother with Mr. Emerson is, that, though he writes in prose, he is
essentially a poet. If you undertake to paraphrase what he says, and to
reduce it to words of one syllable for infant minds, you will make as sad
work of it as the good monk with his analysis of Homer in the “Epistolæ
Obscurorum Virorum.” We look upon him as one of the few men of genius
whom our age has produced, and there needs no better proof of it than his
masculine faculty of fecundating other minds. Search for his eloquence in
his books and you will perchance miss it, but meanwhile you will find that
it has kindled all your thoughts. For choice and pith of language he belongs
to a better age than ours, and might rub shoulders with Fuller and Browne,
—though he does use that abominable word reliable. His eye for a fine,
telling phrase that will carry true is like that of a backwoodsman for a rifle;
and he will dredge you up a choice word from the mud of Cotton Mather
himself. A diction at once so rich and so homely as his I know not where to
match in these days of writing by the page; it is like homespun cloth-of-
gold. The many cannot miss his meaning, and only the few can find it. It is
the open secret of all true genius. It is wholesome to angle in those
profound pools, though one be rewarded with nothing more than the leap of
a fish that flashes his freckled side in the sun and as suddenly absconds in
the dark and dreamy waters again. There is keen excitement, though there
be no ponderable acquisition. If we carry nothing home in our baskets, there
is ample gain in dilated lungs and stimulated blood. What does he mean,
quotha? He means inspiring hints, a divining-rod to your deeper nature. No
doubt, Emerson, like all original men, has his peculiar audience, and yet I
know none that can hold a promiscuous crowd in pleased attention so long
as he. As in all original men, there is something for every palate. “Would
you know,” says Goethe, “the ripest cherries? Ask the boys and the
blackbirds.”
The announcement that such a pleasure as a new course of lectures by
him is coming, to people as old as I am, is something like those forebodings
of spring that prepare us every year for a familiar novelty, none the less
novel, when it arrives, because it is familiar. We know perfectly well what
we are to expect from Mr. Emerson, and yet what he says always penetrates
and stirs us, as is apt to be the case with genius, in a very unlooked-for
fashion. Perhaps genius is one of the few things which we gladly allow to
repeat itself,—one of the few that multiply rather than weaken the force of
their impression by iteration? Perhaps some of us hear more than the mere
words, are moved by something deeper than the thoughts? If it be so, we are
quite right, for it is thirty years and more of “plain living and high thinking”
that speak to us in this altogether unique lay-preacher. We have shared in
the beneficence of this varied culture, this fearless impartiality in criticism
and speculation, this masculine sincerity, this sweetness of nature which
rather stimulates than cloys, for a generation long. If ever there was a
standing testimonial to the cumulative power and value of Character, (and
we need it sadly in these days,) we have it in this gracious and dignified
presence. What an antiseptic is a pure life! At sixty-five (or two years
beyond his grand climacteric, as he would prefer to call it) he has that
privilege of soul which abolishes the calendar, and presents him to us
always the unwasted contemporary of his own prime. I do not know if he
seem old to his younger hearers, but we who have known him so long
wonder at the tenacity with which he maintains himself even in the outposts
of youth. I suppose it is not the Emerson of 1868 to whom we listen. For us
the whole life of the man is distilled in the clear drop of every sentence, and
behind each word we divine the force of a noble character, the weight of a
large capital of thinking and being. We do not go to hear what Emerson says
so much as to hear Emerson. Not that we perceive any falling-off in
anything that ever was essential to the charm of Mr. Emerson’s peculiar
style of thought or phrase. The first lecture, to be sure, was more disjointed
even than common. It was as if, after vainly trying to get his paragraphs
into sequence and order, he had at last tried the desperate expedient of
shuffling them. It was chaos come again, but it was a chaos full of shooting-
stars, a jumble of creative forces. The second lecture, on “Criticism and
Poetry,” was quite up to the level of old times, full of that power of
strangely-subtle association whose indirect approaches startle the mind into
almost painful attention, of those flashes of mutual understanding between
speaker and hearer that are gone ere one can say it lightens. The vice of
Emerson’s criticism seems to be, that while no man is so sensitive to what is
poetical, few men are less sensible than he of what makes a poem. He
values the solid meaning of thought above the subtler meaning of style. He
would prefer Donne, I suspect, to Spenser, and sometimes mistakes the
queer for the original.
To be young is surely the best, if the most precarious, gift of life; yet
there are some of us who would hardly consent to be young again, if it were
at the cost of our recollection of Mr. Emerson’s first lectures during the
consulate of Van Buren. We used to walk in from the country to the
Masonic Temple (I think it was), through the crisp winter night, and listen
to that thrilling voice of his, so charged with subtle meaning and subtle
music, as shipwrecked men on a raft to the hail of a ship that came with
unhoped-for food and rescue. Cynics might say what they liked. Did our
own imaginations transfigure dry remainder-biscuit into ambrosia? At any
rate, he brought us life, which, on the whole, is no bad thing. Was it all
transcendentalism? magic-lantern pictures on mist? As you will. Those,
then, were just what we wanted. But it was not so. The delight and the
benefit were that he put us in communication with a larger style of thought,
sharpened our wits with a more pungent phrase, gave us ravishing glimpses
of an ideal under the dry husk of our New England; made us conscious of
the supreme and everlasting originality of whatever bit of soul might be in
any of us; freed us, in short, from the stocks of prose in which we had sat so
long that we had grown wellnigh contented in our cramps. And who that
saw the audience will ever forget it, where every one still capable of fire, or
longing to renew in them the half-forgotten sense of it, was gathered? Those
faces, young and old, agleam with pale intellectual light, eager with pleased
attention, flash upon me once more from the deep recesses of the years with
an exquisite pathos. Ah, beautiful young eyes, brimming with love and
hope, wholly vanished now in that other world we call the Past, or peering
doubtfully through the pensive gloaming of memory, your light
impoverishes these cheaper days! I hear again that rustle of sensation, as
they turned to exchange glances over some pithier thought, some keener
flash of that humor which always played about the horizon of his mind like
heat-lightning, and it seems now like the sad whisper of the autumn leaves
that are whirling around me. But would my picture be complete if I forgot
that ample and vegete countenance of Mr. R—— of W——,—how, from its
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like