100% found this document useful (2 votes)
353 views

Selenium WebDriver Recipes in Python The problem solving guide to Selenium WebDriver in Python 1st Edition Zhimin Zhan pdf download

The document provides a comprehensive guide to using Selenium WebDriver with Python, featuring various recipes and best practices for automating web testing. It includes detailed instructions on locating web elements, handling hyperlinks, buttons, and form submissions, as well as unit testing. The book is authored by Zhimin Zhan and is available for purchase on Leanpub.

Uploaded by

aquilaplin4w
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
100% found this document useful (2 votes)
353 views

Selenium WebDriver Recipes in Python The problem solving guide to Selenium WebDriver in Python 1st Edition Zhimin Zhan pdf download

The document provides a comprehensive guide to using Selenium WebDriver with Python, featuring various recipes and best practices for automating web testing. It includes detailed instructions on locating web elements, handling hyperlinks, buttons, and form submissions, as well as unit testing. The book is authored by Zhimin Zhan and is available for purchase on Leanpub.

Uploaded by

aquilaplin4w
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/ 58

Selenium WebDriver Recipes in Python The problem

solving guide to Selenium WebDriver in Python


1st Edition Zhimin Zhan download

https://ebookname.com/product/selenium-webdriver-recipes-in-
python-the-problem-solving-guide-to-selenium-webdriver-in-
python-1st-edition-zhimin-zhan/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Selenium design patterns and best practices build a


powerful stable and automated test suite using Selenium
WebDriver Kovalenko

https://ebookname.com/product/selenium-design-patterns-and-best-
practices-build-a-powerful-stable-and-automated-test-suite-using-
selenium-webdriver-kovalenko/

Problem Solving with Algorithms and Data Structures


Using Python SECOND EDITION Bradley N. Miller

https://ebookname.com/product/problem-solving-with-algorithms-
and-data-structures-using-python-second-edition-bradley-n-miller/

Programming in Python 3 A Complete Introduction to the


Python Language 2nd Edition Summerfield

https://ebookname.com/product/programming-in-python-3-a-complete-
introduction-to-the-python-language-2nd-edition-summerfield/

Essentials of Online payment Security and Fraud


Prevention Essentials Series 1st Edition David A.
Montague

https://ebookname.com/product/essentials-of-online-payment-
security-and-fraud-prevention-essentials-series-1st-edition-
david-a-montague/
Recessions Prospects and Developments Prospects and
Developments 1st Edition Nerea M. Pérez

https://ebookname.com/product/recessions-prospects-and-
developments-prospects-and-developments-1st-edition-nerea-m-
perez/

The Last Sorcerers The Path From Alchemy To The


Periodic Table 1st Edition Morris Richard

https://ebookname.com/product/the-last-sorcerers-the-path-from-
alchemy-to-the-periodic-table-1st-edition-morris-richard/

Essentials of Stem Cell Biology 1st Edition R Lanza

https://ebookname.com/product/essentials-of-stem-cell-
biology-1st-edition-r-lanza/

Nanomedicine and the Cardiovascular System 1st Edition


Ross J. Hunter (Editor)

https://ebookname.com/product/nanomedicine-and-the-
cardiovascular-system-1st-edition-ross-j-hunter-editor/

The New Physics for the Twenty First Century 2Rev Ed


Edition Gordon Fraser

https://ebookname.com/product/the-new-physics-for-the-twenty-
first-century-2rev-ed-edition-gordon-fraser/
Microtexture Determination and Its Applications 2nd
Edition Valerie Randle

https://ebookname.com/product/microtexture-determination-and-its-
applications-2nd-edition-valerie-randle/
Selenium WebDriver Recipes in Python
The problem solving guide to Selenium WebDriver in
Python

Zhimin Zhan
This book is for sale at http://leanpub.com/selenium-recipes-in-python

This version was published on 2020-06-12

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean
Publishing process. Lean Publishing is the act of publishing an in-progress ebook using
lightweight tools and many iterations to get reader feedback, pivot until you have the right
book and build traction once you do.

© 2015 - 2020 Zhimin Zhan


Also By Zhimin Zhan
Practical Web Test Automation
Watir Recipes
Selenium WebDriver Recipes in Ruby
Selenium WebDriver Recipes in Java
Learn Ruby Programming by Examples
Learn Swift Programming by Examples
API Testing Recipes in Ruby
Selenium WebDriver Recipes in Node.js
Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Who should read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
How to read this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Recipe test scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Send me feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Selenium language bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Install Selenium Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Cross browser testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 unittest - Python Unit Testing Framework . . . . . . . . . . . . . . . . . . . 8
1.5 Run recipe scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2. Locating web elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14


2.1 Start browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 Find element by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3 Find element by Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Find element by Link Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.5 Find element by Partial Link Text . . . . . . . . . . . . . . . . . . . . . . . . 16
2.6 Find element by XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.7 Find element by Tag Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.8 Find element by Class Name . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.9 Find element by CSS Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.10 Chain find_element to find child elements . . . . . . . . . . . . . . . . . . . 18
2.11 Find multiple elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3. Hyperlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1 Start browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Click a link by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
CONTENTS

3.3 Click a link by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


3.4 Click a link by partial text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.5 Click a link by XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.6 Click Nth link with exact same label . . . . . . . . . . . . . . . . . . . . . . . 22
3.7 Click Nth link by CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.8 Verify a link present or not? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.9 Getting link data attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.10 Test links open a new browser window . . . . . . . . . . . . . . . . . . . . . 24

4. Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 Click a button by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Click a form button by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 Submit a form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Click a button by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.5 Click a button by name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.6 Click a image button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.7 Click a button via JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.8 Assert a button present . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.9 Assert a button enabled or disabled? . . . . . . . . . . . . . . . . . . . . . . . 28

5. TextField and TextArea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29


5.1 Enter text into a text field by name . . . . . . . . . . . . . . . . . . . . . . . 29
5.2 Enter text into a text field by ID . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.3 Enter text into a password field . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.4 Clear a text field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.5 Enter text into a multi-line text area . . . . . . . . . . . . . . . . . . . . . . . 30
5.6 Assert value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.7 Focus on a control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.8 Set a value to a read-only or disabled text field . . . . . . . . . . . . . . . . . 31
5.9 Set and assert the value of a hidden field . . . . . . . . . . . . . . . . . . . . 31

6. Radio button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.1 Select a radio button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2 Clear radio option selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.3 Assert a radio option is selected . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.4 Iterate radio buttons in a radio group . . . . . . . . . . . . . . . . . . . . . . 34
6.5 Click Nth radio button in a group . . . . . . . . . . . . . . . . . . . . . . . . 34
6.6 Click radio button by the following label . . . . . . . . . . . . . . . . . . . . 35
6.7 Customized Radio buttons - iCheck . . . . . . . . . . . . . . . . . . . . . . . 36
CONTENTS

7. CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.1 Select by name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.2 Uncheck a checkbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.3 Assert a checkbox is checked (or not) . . . . . . . . . . . . . . . . . . . . . . 37
7.4 Customized Checkboxes - iCheck . . . . . . . . . . . . . . . . . . . . . . . . 38

8. Select List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.1 Select an option by text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 Select an option by value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.3 Select an option by index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.4 Select an option by iterating all options . . . . . . . . . . . . . . . . . . . . . 40
8.5 Select multiple options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.6 Clear one selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.7 Clear all selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.8 Assert label or value in a select list . . . . . . . . . . . . . . . . . . . . . . . . 41
8.9 Assert selected option label . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.10 Assert the value of a select list . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.11 Assert multiple selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

9. Navigation and Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43


9.1 Go to a URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2 Visit pages within a site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.3 Perform actions from right mouse click context menu such as ‘Back’,
‘Forward’ or ‘Refresh’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.4 Open browser in certain size . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.5 Maximize browser window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.6 Move browser window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.7 Minimize browser window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.8 Scroll focus to control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.9 Switch between browser windows or tabs . . . . . . . . . . . . . . . . . . . 45
9.10 Open new and close browser Tabs . . . . . . . . . . . . . . . . . . . . . . . . 46
9.11 Remember current web page URL, then come back to it later . . . . . . . . 47

10. Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.1 Assert page title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.2 Assert Page Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
10.3 Assert Page Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.4 Assert Label Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
10.5 Assert Span text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CONTENTS

10.6 Assert Div text or HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


10.7 Assert Table text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
10.8 Assert text in a table cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
10.9 Assert text in a table row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
10.10 Assert image present . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
10.11 Assert element location and width . . . . . . . . . . . . . . . . . . . . . . . . 52
10.12 Assert element CSS style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.13 Assert JavaScript errors on a web page . . . . . . . . . . . . . . . . . . . . . 52

11. Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
11.1 Testing Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
11.2 Testing IFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
11.3 Test multiple iframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

12. Testing AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56


12.1 Wait within a time frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
12.2 Explicit Waits until Time out . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
12.3 Implicit Waits until Time out . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
12.4 Create your own polling check function . . . . . . . . . . . . . . . . . . . . . 58
12.5 Wait AJAX Call to complete using JQuery . . . . . . . . . . . . . . . . . . . 58

13. File Upload and Popup dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60


13.1 File upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
13.2 JavaScript pop ups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
13.3 Modal style dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
13.4 Bypass basic authentication by embedding username and password in URL 63
13.5 Internet Explorer modal dialog . . . . . . . . . . . . . . . . . . . . . . . . . . 63
13.6 Popup Handler Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.7 Handle JavaScript dialog with Popup Handler . . . . . . . . . . . . . . . . . 65
13.8 Basic or Proxy Authentication Dialog . . . . . . . . . . . . . . . . . . . . . . 66

14. Debugging Test Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67


14.1 Print text for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
14.2 Write page source or element HTML into a file . . . . . . . . . . . . . . . . 67
14.3 Take screenshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
14.4 Leave browser open after test finishes . . . . . . . . . . . . . . . . . . . . . . 68
14.5 Debug test execution using Debugger . . . . . . . . . . . . . . . . . . . . . . 69
14.6 Attach test executions to an existing browser . . . . . . . . . . . . . . . . . . 71
CONTENTS

15. Test Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73


15.1 Get date dynamically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
15.2 Get a random boolean value . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
15.3 Generate a number within a range . . . . . . . . . . . . . . . . . . . . . . . . 74
15.4 Get a random character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
15.5 Get a random string at fixed length . . . . . . . . . . . . . . . . . . . . . . . 75
15.6 Get a random string in a collection . . . . . . . . . . . . . . . . . . . . . . . 75
15.7 Generate random person names, emails, addresses with Faker . . . . . . . . 75
15.8 Generate a test file at fixed sizes . . . . . . . . . . . . . . . . . . . . . . . . . 76
15.9 Retrieve data from Database . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

16. Browser Profile and Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78


16.1 Get browser type and version . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
16.2 Set HTTP Proxy for Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
16.3 Verify file download in Chrome . . . . . . . . . . . . . . . . . . . . . . . . . 79
16.4 Test downloading PDF in Firefox . . . . . . . . . . . . . . . . . . . . . . . . . 79
16.5 Bypass basic authentication with Firefox AutoAuth plugin . . . . . . . . . . 80
16.6 Manage Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
16.7 Headless browser testing with PhantomJS . . . . . . . . . . . . . . . . . . . 83
16.8 Headless Chrome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
16.9 Headless Firefox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
16.10 Test responsive websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.11 Set page load timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
16.12 Device emulation on Chrome . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

17. Advanced User Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87


17.1 Double click a control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
17.2 Move mouse to a control - Mouse Over . . . . . . . . . . . . . . . . . . . . . 88
17.3 Click and hold - select multiple items . . . . . . . . . . . . . . . . . . . . . . 88
17.4 Context Click - right click a control . . . . . . . . . . . . . . . . . . . . . . . 88
17.5 Drag and drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
17.6 Drag slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
17.7 Send key sequences - Select All and Delete . . . . . . . . . . . . . . . . . . . 90
17.8 Click a specific part of an image . . . . . . . . . . . . . . . . . . . . . . . . . 91

18. HTML 5 and Dynamic Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93


18.1 HTML5 Email type field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
18.2 HTML5 Time Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
18.3 Invoke ‘onclick’ JavaScript event . . . . . . . . . . . . . . . . . . . . . . . . . 94
CONTENTS

18.4 Invoke JavaScript events such as ‘onchange’ . . . . . . . . . . . . . . . . . . 95


18.5 Scroll to the bottom of a page . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
18.6 Select2 - Single Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
18.7 Select2 - Multiple Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
18.8 AngularJS web pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
18.9 Ember JS web pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
18.10 “Share Location” with Firefox . . . . . . . . . . . . . . . . . . . . . . . . . . 104
18.11 Faking Geolocation with JavaScript . . . . . . . . . . . . . . . . . . . . . . . 105
18.12 Save a canvas to PNG image . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
18.13 Verify dynamic charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

19. WYSIWYG HTML editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107


19.1 TinyMCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
19.2 CKEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
19.3 SummerNote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
19.4 CodeMirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

20. Leverage Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111


20.1 Raise exceptions to fail test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
20.2 Ignorable test statement error . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
20.3 Read external file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
20.4 Data-Driven Tests with Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
20.5 Data-Driven Tests with CSV . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
20.6 Identify element IDs with dynamically generated long prefixes . . . . . . . 115
20.7 Sending special keys such as Enter to an element or browser . . . . . . . . . 116
20.8 Use of unicode in test scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
20.9 Extract a group of dynamic data : verify search results in order . . . . . . . 116
20.10 Verify uniqueness of a set of data . . . . . . . . . . . . . . . . . . . . . . . . 117
20.11 Extract dynamic visible data rows from a results table . . . . . . . . . . . . 118
20.12 Extract dynamic text following a pattern using Regex . . . . . . . . . . . . . 120
20.13 Quick extract pattern text in comments with Regex . . . . . . . . . . . . . . 121

21. Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123


21.1 Assert page_source is faster than page text . . . . . . . . . . . . . . . . . . . 123
21.2 Getting text from specific element is faster . . . . . . . . . . . . . . . . . . . 124
21.3 Avoid programming if-else block if possible . . . . . . . . . . . . . . . . . . 124
21.4 Use variable to cache not-changed data . . . . . . . . . . . . . . . . . . . . . 124
21.5 Enter large text into a text box . . . . . . . . . . . . . . . . . . . . . . . . . . 125
21.6 Use Environment Variables to change test behaviours dynamically . . . . . 126
CONTENTS

21.7 Test web site in two languages . . . . . . . . . . . . . . . . . . . . . . . . . . 127


21.8 Multi-language testing with lookups . . . . . . . . . . . . . . . . . . . . . . . 128

22. Gotchas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131


22.1 Test starts browser but no execution with blank screen . . . . . . . . . . . . 131
22.2 Failed to assert copied text in browser . . . . . . . . . . . . . . . . . . . . . . 132
22.3 The same test works for Chrome, but not IE . . . . . . . . . . . . . . . . . . 133
22.4 “unexpected tag name ‘input’” . . . . . . . . . . . . . . . . . . . . . . . . . . 134
22.5 Element is not clickable or not visible . . . . . . . . . . . . . . . . . . . . . . 134

23. Material Design Web App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136


23.1 Select List (dropdown) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
23.2 Checkbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
23.3 Drag range (noUiSlider) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
23.4 Verify Toast message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
23.5 Modal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

24. Selenium Remote Control Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139


24.1 Selenium Server Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
24.2 Execute tests in specified browser on another machine . . . . . . . . . . . . 140
24.3 Selenium Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

Appendix - Continuous Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145


Verify server machine can run Selenium Python . . . . . . . . . . . . . . . . . . . . 145
Install BuildWise Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Create Build Project in BuildWise . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Trigger test execution manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Feedback while test execution in progress . . . . . . . . . . . . . . . . . . . . . . . . 149
Build finished . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Notification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Preface
After observing many failed test automation attempts by using expensive commercial test
automation tools, I am delighted to see that the value of open-source testing frameworks has
finally been recognized. I still remember the day (a rainy day at a Gold Coast hotel in 2011)
when I found out that the Selenium WebDriver was the most wanted testing skill in terms
of the number of job ads on the Australia’s top job-seeking site.
Now Selenium WebDriver is big in the testing world. We all know software giants such
as Facebook and LinkedIn use it, immensely-comprehensive automated UI testing enables
them pushing out releases several times a day¹. However, from my observation, many
software projects, while using Selenium, are not getting much value from test automation,
and certainly nowhere near its potential. A clear sign of this is that the regression testing is
not conducted on a daily basis (if test automation is done well, it will happen naturally).
Among the factors contributing to test automation failures, a key one is that automation
testers lack sufficient knowledge in the test framework. It is quite common to see some
testers or developers get excited when they first create a few simple test cases and see them
run in a browser. However, it doesn’t take long for them to encounter some obstacles: such as
being unable to automate certain operations. If one step cannot be automated, the whole test
case does not work, which is the nature of test automation. Searching solutions online is not
always successful, and posting questions on forums and waiting can be frustrating (usually,
very few people seek professional help from test automation coaches). Not surprisingly,
many projects eventually gave up test automation or just used it for testing a handful of
scenarios.
The motivation of this book is to help motivated testers work better with Selenium. The book
contains over 190 recipes for web application tests with Selenium. If you have read one of
my other books: Practical Web Test Automation², you probably know my style: practical. I
will let the test scripts do most of the talking. These recipe test scripts are ‘live’, as I have
created the target test site and included offline test web pages. With both, you can:

1. Identify your issue


2. Find the recipe
¹http://www.wired.com/business/2013/04/linkedin-software-revolution/
²https://leanpub.com/practical-web-test-automation
Preface ii

3. Run the test case


4. See test execution in your browser

Who should read this book


This book is for testers or programmers who are writing (or want to learn) automated tests
with Selenium WebDriver. In order to get the most of this book, basic Ruby coding skill is
required.

How to read this book

Usually, a ‘recipe’ book is a reference book. Readers can go directly to the part that interests
them. For example, if you are testing a multiple select list and don’t know how, you can look
up in the Table of Contents, then go to the chapter 8. This book supports this style of reading.
If you are new to Selenium WebDriver, I recommend you to try out the recipes from the
front to back. The recipes in the first half of the book are arranged according to their levels of
complexity, I believe readers can get the pattern of testing with Selenium and gain confidence
after going through them.

Recipe test scripts


To help readers to learn more effectively, this book has a dedicated site³ that contains the
recipe test scripts, test web pages and related resources. For access code, please see the
Resources section of this book.
As an old saying goes, “There’s more than one way to skin a cat.” You can achieve the same
testing outcome with test scripts implemented in different ways. The recipe test scripts in
this book are written for simplicity, and there is always room for improvement. But for many,
to understand the solution quickly and get the job done are probably more important.
If you have a better and simpler way, please let me know.
All recipe test scripts are Selenium WebDriver 3 compliant, and can be run against Chrome,
Firefox and Internet Explorer on multiple platforms. I plan to keep the test scripts updated
with the latest stable Selenium version.
³http://zhimin.com/books/selenium-recipes-nodejs
Preface iii

Send me feedback
I would appreciate your comments, suggestions, reports on errors in the book and the recipe
test scripts. You may submit your feedback on the book’s site.

Zhimin Zhan
Brisbane, Australia
1. Introduction
Selenium is a free and open source library for automated testing web applications. Selenium
was originally created in 2004 by Jason Huggins, it merged with another test framework
WebDriver in 2011 (that’s why is named ‘selenium-webdriver’) led by Simon Stewart at
Google (update: Simon now works at FaceBook). As WebDriver is a W3C standard¹, it gains
support from all major browser vendors, as a result, Selenium WebDriver quickly become
the de facto framework for automated testing web applications.

1.1 Selenium language bindings


Selenium tests can be written in multiple programming languages such as Java, C#, Python,
JavaScript and Ruby (the core ones). Quite commonly, I heard the saying such as “This is a
Java project, so we shall write tests in Java as well”. I disagree. Software testing is to verify
whether programmer’s work meets customer’s needs. In a sense, testers are representing
customers. Testers should have more weight on deciding the test syntax than programmers.
Plus, why would you mandate that your testers should have the same programming language
skills as the programmers. In my subjective view, scripting languages such as Ruby and
Python are more suitable for test scripts than compiled languages such as C# and Java
(Confession: I have been programming in Java for over 10 years). By the way, we call them
test scripts, for a reason.
All examples in this book are written in Selenium with Python binding. This does not mean
this book is limited to testers/developers who know Python. As you will see the examples
below, the use of Selenium in different bindings are very similar. Once you master one, you
can apply it to others quite easily. Take a look at a simple Selenium test script in five different
language bindings: Java, C#, JavaScript, Ruby and Python.
Java:

¹https://www.w3.org/TR/webdriver/
Introduction 2

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GoogleSearch {


public static void main(String[] args) {
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();

// And now use this to visit Google


driver.get("http://www.google.com");

// Find the text input element by its name


WebElement element = driver.findElement(By.name("q"));

// Enter something to search for


element.sendKeys("Hello Selenium WebDriver!");

// Submit the form based on an element in the form


element.submit();

// Check the title of the page


System.out.println("Page title is: " + driver.getTitle());
}
}

C#:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

class GoogleSearch
{
static void Main()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Hello Selenium WebDriver!");
Introduction 3

query.Submit();
Console.WriteLine(driver.Title);
}
}

JavaScript:

var webdriver = require('selenium-webdriver');


var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();

driver.get('http://www.google.com/ncr');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(webdriver.until.titleIs('webdriver - Google Search'), 1000);
console.log(driver.title);

Ruby:

require "selenium-webdriver"

driver = Selenium::WebDriver.for :firefox


driver.navigate.to "http://www.google.com"

element = driver.find_element(:name, 'q')


element.send_keys "Hello Selenium WebDriver!"
element.submit

puts driver.title

Python:

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("http://www.google.com")

elem = driver.find_element_by_name("q")
elem.send_keys("Hello WebDriver!")
elem.submit()

print(driver.title)
Introduction 4

1.2 Install Selenium Python


1. Download and install Python.
Python 2 is pre-installed on Mac and most Linux distributions. For new Python
projects, I would recommend Python 3, which was first released in 2008. Here are
the instructions to install Python on Windows.
Download latest installer² and run the installer.

Accept all default options except “Add python.exe to Path” for convenience.
For Mac,
brew install python3

2. Install Selenium-WebDriver for Python.


PIP is the package manager for Python. PIP comes with Python installer, run the
command below to upgrade to the latest PIP version.
> python -m pip install --upgrade pip

Install Selenium-WebDriver for Python.

²https://www.python.org/downloads
Introduction 5

C:\Users\Administrator>pip3 install selenium


Collecting selenium
Downloading selenium-3.141.0-py2.py3-none-any.whl (904kB)
100% |################################| 911kB 525kB/s
Installing collected packages: selenium
Collecting urllib3 (from selenium)
Downloading urllib3-1.24-py2.py3-none-any.whl (117kB)
Successfully installed selenium-3.141.0 urllib3-1.24

3. Your target browses are installed, such as Chrome and Firefox.

Now you are ready to run Selenium script. Type in the above python script (google search)
in a text editor such as NotePad and save as “google_search.py”. Run the command below
in a command window.

> py google_search.py

You will see Firefox browser starting up and performing a Google search.

1.3 Cross browser testing


The biggest advantage of Selenium over other web test frameworks, in my opinion, is
that it supports all major web browsers: Firefox, Chrome and Internet Explorer/Edge. The
browser market nowadays is more diversified (based on the StatsCounter³, the usage share
in December 2017 for Chrome, IE/Edge and Firefox are 64.7%, 12.2% and 11.9% respectively).
It is logical that all external facing web sites require serious cross-browser testing. Selenium
is a natural choice for this purpose, as it far exceeds other commercial tools and free test
frameworks..

Chrome

To run Selenium tests in Google Chrome, besides the Chrome browser itself, ChromeDriver
needs to be installed.
Installing ChromeDriver is easy: go to ChromeDriver site⁴.
³http://en.wikipedia.org/wiki/Usage_share_of_web_browsers
⁴https://sites.google.com/a/chromium.org/chromedriver/downloads
Introduction 6

Download the one for your target platform, unzip it and put chromedriver executable in
your PATH. To verify the installation, open a command window (terminal for Unix/Mac),
execute command chromedriver, You shall see:
Starting ChromeDriver 80.0.3987.16 (....) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent
access by malicious code.

The test script below opens a site in a new Chrome browser window and closes it one second
later.
from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get("http://testwisely.com/demo")
time.sleep(1) # wait 1 second
driver.quit()

For readers who can’t wait to see the test running, below is the command you need to use to
execute a test, which you can download from the book’s site (Python and selenium library
need to be installed first. See instructions towards the end of this chapter).
> python ch01_open_chrome.py

Firefox
Selenium tests requires Gecko Driver⁵ to drive Firefox. The test script below will open a web
site in a new Firefox window.
⁵https://github.com/mozilla/geckodriver/releases/
Introduction 7

from selenium import webdriver


driver = webdriver.Firefox()
driver.get("http://testwisely.com/demo")

Internet Explorer

Selenium requires IEDriverServer to drive IE browser. Its installation process is very similar
to ChromeDriver. IEDriverServer is available at https://www.selenium.dev/downloads⁶.
Choose the right one based on your windows version (32 or 64 bit).

When a tests starts to execute in IE, before navigating the target test site, you will see this
first:

Depending on the version of IE, configurations may be required. Please see IE and IEDri-
verServer Runtime Configuration⁷ for details.

from selenium import webdriver


driver = webdriver.Ie()
driver.get("http://testwisely.com/demo")

Edge

Edge is Microsoft’s new and default web browser on Windows 10. To drive Edge with
WebDriver, you need download Microsoft WebDriver⁸. After installation, you will find the
executable (MicrosoftWebDriver.exe) under Program Files folder, add it to your PATH.
However, I couldn’t get it working after installing a new version of Microsoft WebDriver.
One workaround is to specify the driver path in test scripts specifically:

⁶https://www.selenium.dev/downloads
⁷https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration
⁸https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Introduction 8

from selenium import webdriver


import time
import os

# copy MicrosoftWebDriver.exe to the test script directory


dir = os.path.dirname(__file__)
edge_path = dir + "\MicrosoftWebDriver.exe"
driver = webdriver.Edge(edge_path)
driver.get("http://testwisely.com/demo")

1.4 unittest - Python Unit Testing Framework


The above scripts drive browsers, strictly speaking, they are not tests. To make the effective
use of Selenium scripts for testing, we need to put them in a test syntax framework that
defines test structures and provides assertions (performing checks in test scripts). In this
book, I use unittest, also known as “PyUnit”, the unit testing framework for Python. Here is
an example.

import unittest
from selenium import webdriver

class FooBarTestCase(unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome()

@classmethod
def tearDownClass(cls):
cls.driver.quit()

def setUp(self):
self.driver.get("http://travel.agileway.net")

def tearDown(self):
self.driver.find_element_by_link_text("Sign off").click()

def test_first_case(self):
self.assertEqual("Agile Travel", self.driver.title)
self.driver.find_element_by_name("username").send_keys("agileway")
# ...
Introduction 9

def test_second_case(self):
self.driver.find_element_by_id("register_link").click()
# ...
self.assertIn("Register", self.driver.find_element_by_tag_name("body").text)

The keywords class, setUpClass, setUp and def test_xxx define the structure of a test
script file.

• class FooBarTestCase(unittest.TestCase):
Test suite name for grouping related test cases.
• setUpClass() and tearDownClass().
Optional test statements run before and after all test cases, typically starting a new
browser window in setupClass and close it in tearDownClass.
• setUp() and tearDown().
Optional test statements run before and after each test case.
• def test_xxx(self):
Individual test cases.
• Assertions
assertEqual() and assertIn are PyUnit’s two assertion methods which are used to
perform checks. More assert methods⁹

You will find more about unittest from its home page¹⁰. However, I honestly don’t think it
is necessary. The parts used for test scripts are not much and quite intuitive. After studying
and trying out some examples, you will be quite comfortable with it.

1.5 Run recipe scripts


Test scripts for all recipes can be downloaded from the book site. They are all in ready-to-run
state. I include the target web pages/sites as well as Selenium test scripts. There are two kinds
of target web pages: local HTML files and web pages on a live site. Running tests written for
a live site requires Internet connection.
⁹https://docs.python.org/3/library/unittest.html#assert-methods
¹⁰https://docs.python.org/3/library/unittest.html
Introduction 10

Run tests in PyCharm IDE

The most convenient way to run one test case or a test suite is to do it in an IDE, such as
PyCharm.

When you have a large number of test cases, then the most effective way to run
all tests is done by a Continuous Integration process.

Find the test case

You can locate the recipe either by following the chapter or searching by name. There are
over 150 test cases in the recipes test project. Here is the quickest way to find the one you
want in PyCharm.
Select menu ‘Navigation’ → ‘Go to Symbol …’.

A pop up window lists all test cases in the project for your selection. The finding starts as
soon as you type.

Run individual test case

Move mouse to a line within a test case (starting def test_xxx)(self):). Right click and
select “Run ‘Unittest test_xxx’” to run this case.
Introduction 11

The below is a screenshot of execution panel when one test case failed,

Run all test cases in a test script file

You can also run all test cases in a test script file by right clicking the file name in the project
pane and select “Run ‘Unittests in test_file.py’”.
Introduction 12

The below is a screenshot of the execution panel when all test cases in a test script file passed,

Run tests from command line


One advantage of open-source test frameworks, such as Selenium, is FREEDOM. You can
edit the test scripts in any text editors and run them from a command line.
To run test cases in a test script file (named google_test.py), enter command
Discovering Diverse Content Through
Random Scribd Documents
A. Lincoln
CHAPTER I.

INTRODUCTORY.

The rebellion of the slave-holding states, and the attempt to


establish a separate government by force of arms, was solely in the
interest of the institution of slavery. The Southern Confederacy was
to rest on this institution as its corner-stone. By the establishment of
the Confederacy it was intended to end, forever, the agitation of this
question, and establish the system of human slavery as one of the
permanent institutions of the world. And all this in the nineteenth
century of the Christian era! Preparatory to this the pulpit and the
press had been suborned, the Christian conscience of the country
had been debauched, and the doctrine that slavery was a Divine
institution was taught, and accepted as true, by one-half of the
American people.
A doctor of divinity, or even a common preacher, who could
prove this to his own satisfaction, and that of his hearers, at once
achieved popularity, and had his great learning and ability heralded
by the secular press throughout the South land. Neither was this
kind of preaching confined to the South. It found a distinct and
earnest echo in many places in the North. It was argued, and no
doubt sincerely believed, that slavery was the best condition for
securing the happiness and welfare of the African race—the
condition in which the negro could be most useful to the world; that
his condition had been greatly improved by his transplantation from
a heathen land and the environments of barbarism to a Christian
land and civilized and Christian environments; and that subjection to
a higher and superior race was necessary to his deriving the highest
benefit from the change. Slavery, it was taught, was a patriarchal
institution, and that it was only through it that the highest ideal of
human civilization could be attained. It was natural that a people
whose judgment had crystalized around such opinions as these
should be intolerant of opposition, as they had closed the door to
discussion on this question; and so for several generations a
contrary opinion was not tolerated, or allowed to find expression, in
the slave-holding states. The agitation of this question, in its moral
aspects, by constantly increasing numbers of earnest, able men in
the North, at last led to the organization of a political party opposed
to this institution, and the question of slavery thus became a political
question.
The friends of the institution instinctively recognized the danger
that thus confronted them, and began to strengthen their fences by
most stringent measures to repress discussion and shut out the
light. This was a tacit admission that they felt themselves unable to
stand before the world in argument. It may be laid down as an
axiom, that whenever a political party forecloses discussion on any
subject, but more especially on a great moral issue, it is not only on
the wrong side of that issue, but has an intuitive perception of that
fact.
It may also be accepted as an axiom, that the more inconsistent
a man's attitude is on any great moral question the more intolerant
will he be of opposition. Not only were the most stringent laws
passed to prevent the discussion of the institution of slavery in its
moral aspects in the Southern States, but also the most lawless and
violent measures were resorted to, so that it was as much as a
man's life was worth to undertake to make a public argument
against slavery in a slave-holding state, and even to be found
earnestly opposed to the institution in sentiment was to put personal
safety in jeopardy. The making of this question a political question
tended largely to de-sectionalize it. No party could hope to succeed,
as a National party, without the vote of the South, and this could
only be secured by concessions to the demands of the slave holders
in the interest of that institution; and so the party that was willing to
concede the most to their demands became the dominant party in
the nation. Thus the leading Democratic politicians, all over the
North, became the staunch advocates of slavery; and we all know
with what blind confidence, and fierce determination, the masses
follow their political leaders. The culmination of the contest over this
question, resulting in the election of Abraham Lincoln to the
Presidency by a party openly opposed to slavery, caused its friends
to take their appeal from the ballot box to the sword; and this
appeal found those who were the friends of the institution from
political party considerations scattered all over the North in quite
formidable numbers, constituting an enemy in the rear of our armies
that gave to the administration of President Lincoln no little anxiety
and embarrassment, making it necessary for him, as early as
September, 1862, to proclaim martial law and suspend the writ of
habeas corpus in respect to all persons in the United States who
were found to be actively disloyal, and engaged in efforts to aid the
rebellion. The following is a copy of his proclamation:—

GENERAL ORDERS NO. 141.


War Department,
Adjutant General's Office,
Washington, Sept. 25, 1862.
The following Proclamation by the President is published
for the information and government of the Army and all
concerned:
By the President of the United States of America.
A Proclamation.
Whereas it has become necessary to call into service not
only volunteers but also portions of the militia of the States
by draft, in order to suppress the insurrection existing in the
United States, and disloyal persons are not adequately
restrained by the ordinary processes of law from hindering
this measure and from giving aid and comfort in various ways
to the insurrection: Now, therefore, be it ordered: First, That
during the existing insurrection, and as a necessary measure
for suppressing the same, all rebels and insurgents, their
aiders and abettors, within the United States, and all persons
discouraging volunteer enlistments, resisting militia drafts, or
guilty of any disloyal practice affording aid and comfort to
rebels against the authority of the United States shall be
subject to martial law, and liable to trial and punishment by
court-martial or military commission. Second, That the writ of
habeas corpus is suspended in respect to all persons arrested,
or who are now, or hereafter during the rebellion shall be,
imprisoned in any fort, camp, arsenal, military prison, or other
place of confinement, by any military authority, or by
sentence of any court-martial or military commission. In
witness whereof I have hereunto set my hand, and caused
the seal of the United States to be affixed.
Done at the city of Washington, this twenty-fourth day of
September, in the year of our Lord one thousand eight
hundred and sixty-two, and of the Independence of the
United States the eighty-seventh.
ABRAHAM LINCOLN.
"By the President,
"William H. Seward, Secretary of State.
By order of the Secretary of War,
"L. Thomas, Adjutant General."
"Official."

This disloyal element was rendered much more formidable by


the fact of its perfect combination, through secret, oath-bound
organizations under the names of Knights of the Golden Circle and
Order of American Knights. These secret orders no doubt had their
origin in the South, preparatory to secession and war; but after the
war had been commenced it was chiefly in the North that they were
useful to the rebel cause, and it was through these that the
assassination of the President-elect was to have been accomplished
at Baltimore when on his way to the Capital in 1861, and thus his
inauguration as President was to have been prevented. We thus see
the desperate character of the political leaders of the rebellion, who
were ready to frustrate the expressed will of the people by resorting
to assassination. We need not think strange that a rebellion which
was ready to resort to such means in its incipiency should finally
expire under the weight of this infamy.
By these secret organizations, the enemies of the government,
wherever they might be, possessed the means of a secret
recognition amongst their members. And under whatever
circumstances they might be placed, the obligations of their oath
afforded them confidence and security. They constituted a
brotherhood, and by their secret grips, signs, passwords, etc., they
had a guarantee of unity of sentiment and of purpose, and of
faithfulness to each other and to the obligations of their oath.
These organizations were regarded as allies by the rebel
government, and were counted on as a valuable factor to secure the
success of its arms. This element in the North kept itself in constant
communication with the rebel government and the rebel armies, and
thus, in a large degree, filled the place of spies in giving information.
To furnish facilities for communication with its friends in the North,
as also for various other purposes in aid of the rebel cause, the
Confederate Government sent a number of its ablest civilians to
Canada, at an early period of the war, as its secret agents, who
established their headquarters at Montreal. This cabal consisted of
the following persons: Jacob Thompson, who had been Secretary of
the Interior under Buchanan's administration; Clement C. Clay, who
had been a United States Senator from Alabama; Beverly Tucker,
who had been a Circuit Judge in Virginia; George N. Sanders,
William C. Cleary, Prof. Holcomb, George Harper, and others. Of
these, Thompson, Tucker, and Clay seem to have held semi-official
positions, and we will designate them as Davis's Canada Cabinet.
The others named, as also others unnamed above, appear to have
acted as aids, in a subordinate capacity, in the execution of their
plots. They all claimed to be acting as agents of the Rebel
Government upon their oaths on the trial for the extradition of the
St. Alban's raiders.
The proclamation of martial law and suspension of the writ of
habeas corpus in September, 1862, had the effect of restraining the
open, active efforts of these secret disloyal organizations to cripple
the resources at Mr. Lincoln's command for suppressing the
rebellion, inasmuch as any such efforts were met by arrest, military
trial, and imprisonment; yet, inasmuch as they created a necessity
for a military police at all important points in the North, they felt that
they were still rendering valuable service to the rebellion by thus
weakening the force at the front; and whilst it was necessary to
conduct their operations with much more secrecy, their organizations
were not disbanded. They went on to effect a complete military
organization, thoroughly officered and drilled, and in many cases
armed, holding themselves ready to take the field in any emergency
that might arise that would justify so bold a measure. The Canada
Cabinet watched over these organizations with great interest, and
directed their operations, and by many schemes sought to bring
about an emergency that would enable them to bring this army,
which they had hidden away in secrecy, into the field of active
operations for the success of their cause. The officers of these secret
military organizations were chosen from the local political leaders in
the different localities where they existed, and kept themselves in
communication with the Canada Cabinet, and through this medium
the Confederate Government was kept informed of their strength,
organization, plans, and purposes. So bold and active did they
become, in spite of the efforts of the military police for their
suppression, that the government finally found it necessary, through
its secret service department, to possess itself of a thorough
knowledge of these organizations, and in this way was enabled to
capture the arms and munitions of war which had been secured and
were hidden away in secrecy by them, and also to arrest the leading
officers of these organizations in several states. Whilst by these
means these treasonable combinations were seriously crippled, they
were unchanged in animus and still struggled to maintain their
existence. They kept themselves in communication with the Canada
conspirators, and ready to co-operate with them for the success of
their schemes should the conditions become sufficiently promising to
justify them in declaring themselves openly.
It was in the summer of 1864 that Jacob Thompson, according
to the testimony before the Commission, declared that he had his
friends all over the Northern States, who were willing to go to any
length in order to serve the cause of the South. Jefferson Davis's
Canada Cabinet kept up a constant correspondence with their chief,
through secret agents who travelled directly through the states, and
even through the city of Washington.
So potent was the aid of secret signs, grips, pass-words, etc., as
a means of recognition, and so universally were the members of
these secret orders diffused over the country, that they could go
anywhere. Should one agent find it necessary to stop his task for
fear of detection, another would take it up; and where men could
not go, women went, to carry communications. The Canada Cabinet
was well supplied with money by the government at Richmond, and
in this department of the service Jacob Thompson seems to have
been Secretary of the Treasury. He kept his deposits largely in the
Ontario Bank of Montreal, and his credits there arose from Southern
bills of exchange on London. The object of the writer in this
introductory chapter has been to place clearly before his readers the
formidable character of the conspiracy, which, with the President of
the Confederacy at its head, and organized by his Canada Cabinet,
was intended to throw the loyal North into a state of chaotic
confusion and bring to the aid of their sinking cause the disloyal
element all over the North, by a series of assassinations which would
leave the nation without a civil and military head and without any
constitutional way of electing another President, and at the same
time would deprive the armies of the United States of a lawful
commander. This was the last card of the political leaders of the
rebellion, the last desperate resort to retrieve a cause that had been
manifestly lost in open warfare. It may seem like temerity in the
writer to make such a charge involving a total disregard of the laws
of civilized warfare, and such utter moral depravity on the part of
these conspirators, and to claim for their wicked project the approval
of Jefferson Davis, but the evidence in the possession of the
government and adduced before the Commission, it will be seen,
fully justified the government in making this charge. The persons
brought before the Commission, though in full sympathy in
sentiment with their employers, were merely the tools and hired
assassins of the Canada Cabinet, acting under the advice and
sanction of their chief. I shall now proceed to bring before my
readers the denouement of their plot, and, from the evidence given
before the Commission, show that the origin, scope and purpose of
the conspiracy have been truly indicated above.
CHAPTER II.

PREPARATIONS FOR THE


EXECUTION OF THE PLOT.

The evidence which will be hereafter referred to shows that John


Wilkes Booth and John H. Surratt had, as early as the latter part of
October, or early in November, 1864, entered into a contract with
Davis's Canada Cabinet to accomplish the assassinations they had
planned, and that they immediately entered upon their work of
preparation. It would seem from the evidence, that at that time the
purpose was to execute their designs at a much earlier date than
they did; and that this delay was occasioned by the Canada
conspirators.
J. WILKES BOOTH.

Surratt and Booth, however, were busied from that time on in


making their preparations. The first step was to enlist in the
conspiracy a sufficient number of competent and reliable assistants,
to each one of whom was assigned the part he was to take in it, and
to train, equip, and prepare him for the part assigned him. The
assassination of President Lincoln had fallen to Payne by lot; and to
him was entrusted the task of making all needed preparations.
Payne had visited Canada during the fall of 1864, and probably there
made the acquaintance of Booth. To a man of Booth's sagacity, a
mere glance at Payne would be sufficient to impress him with the
idea that he was one of the helpers he wanted; and as we find him
as early as February, 1865, transplanted to Washington City by
Booth and Surratt, and from that time on associating with them very
intimately but very secretly, and without employment, or visible
means, passing back and forth between Washington and Baltimore,
and finally provided with quarters in Washington by Surratt, there
can be no doubt that he was early enlisted in the conspiracy, and
supported by the Canada Cabinet through their agents in
Washington—Booth and Surratt. The author is led to conclude from
studying the evidence that Booth and Surratt were acting under a
considerable latitude of provisional instructions, and that to them
was entrusted the selection of the time and place for the
accomplishment of their purpose. There were a number of persons
in Canada, members of the conspiracy, who were expected to take
an active part in its execution; and it is altogether probable that the
original plan contemplated the accomplishment of these
assassinations as opportunities could be found or made, and that for
each one a man had been assigned.
John Wilkes Booth and John Harrison Surratt were the leaders of
the conspiracy in Washington, they having proposed to their co-
conspirators in Canada to accomplish for them the assassinations
they had planned.
They were stimulated by their intense hostility to the
administration of President Lincoln and desire for the establishment
of the Southern Confederacy, and also by the delusive idea of
winning enduring fame and the lasting gratitude of their countrymen
of the South for being thus the instruments of retrieving the fortunes
of their dying cause. But in addition to these considerations, they
had large promises of pecuniary reward. They were, in fact, the
hired assassins of Jefferson Davis and his Canada Cabinet.
These two men had been engaged for months in making their
preparations for the assassination of the President, Vice-President,
Secretary Seward, and General Grant. They visited and conferred
with the Canada conspirators from time to time during the summer
and fall of 1864, and early winter of 1865. They traversed the
counties of Prince George, Charles, and St. Mary's, Maryland, lying
along the north side of the Potomac below Washington, to prepare
the way for escape by securing confederates along the contemplated
route who would assist in facilitating their flight by aiding them in
their progress, or by concealing them if necessary. Booth had spent
some time in this work during the fall and early winter, making
himself familiar with the geography of the country, roads, etc., under
the pretence that he desired to purchase lands in Maryland. He
found in Charles County Dr. S. A. Mudd, who sympathized with his
plans, and entered into them at least so far as to pledge him any
assistance he could give him in making his escape. Mudd also visited
Booth two or three times in Washington during the winter,
introducing him on the occasion of his first visit to John H. Surratt;
and in the course of these visits he was always found in company
with Booth and others of the conspirators who were to take an
active part in its accomplishment, and was no doubt kept well
informed of the progress of their preparations, and of the time when
it would be attempted after that had been determined upon. Surratt
also spent much time during the winter in this part of Maryland, in
preparation for the work. Being at home there, he could render
Booth valuable assistance by procuring friends who would aid him in
his flight, and in getting him across the Potomac at the selected
point. As this was on the line of a regular underground mail route
between Washington and Richmond, with which Surratt was familiar,
he, of course, had no difficulty in making satisfactory arrangements,
the great mass of the population in all of these counties being
intensely disloyal.
They had selected and arranged with Payne, Atzerodt,
O'Laughlin, Arnold, Herold, Spangler, and numerous other parties
who were never made known, to take an active part in the work of
assassination, or to aid them in their escape. Booth and Surratt had
provided horses for the occasion, and, with Atzerodt and Herold,
were known to a number of liverymen of whom they were liberal
and frequent patrons.
Surratt provided quarters for Payne at the Herndon House,
representing him to be a delicate gentleman, and stipulating that his
meals should be served to him in his room. Atzerodt, who was to
have assassinated the Vice-President, had taken a room at the
Pennsylvania House. Booth, being an actor, and familiar with the
routine of the play and the work of the assistants on the stage,
having selected Ford's Theatre as the place for the accomplishment
of his purpose, proceeded to make himself at home amongst the
habitues of that establishment. He was a very handsome man,
stylish in his dress, dissolute in his habits, a constant and free
drinker, generous in the expenditure of his money on his vices of
smoking and drinking, and of great personal magnetism. He soon
ingratiated himself with the employees of the theatre, and became a
general favorite.
It was necessary that he should have a co-conspirator at the
theatre to assist him in making his escape. He had labored hard with
an actor in New York by the name of Chester, with whom he was
acquainted, to engage him in the conspiracy, that he might station
him at the door of his exit, to see that his way should be clear and
the door open at the critical moment, for which service he offered to
pay him three thousand dollars; but Chester, after several interviews
and much importunity, absolutely declined, and begged Booth never
to mention the matter to him again. Failing to secure Chester, he
turned his attention to Edward Spangler, an employee at the theatre.
Spangler was a man of dissipated habits, low moral tone, and little
intellectual culture, and being politically in sympathy with Booth, he
was easily led by him into the conspiracy. Booth had had a shed
fitted up as a stable in an alley back of the theatre, and had kept his
horse in it occasionally for some time previous, that he might have it
convenient when the supreme moment should have arrived, without
exciting suspicion. To reach the private box fitted up on the occasion
for the occupancy of the President and General Grant, with their
wives, it was necessary to pass through two doors. The first led into
a passage behind the box, the second from this passage into the
box. To prevent any one from following him into the passage and
hindering the accomplishment of his purpose, Booth had cut,
himself, or more likely had had Spangler, who was a kind of rough
carpenter, cut a mortise in the plastering of the passage wall, in such
a position with reference to the door that the end of a wooden bar,
three and a half feet long, which had been prepared for that
purpose, could be inserted in the mortise, and the other end placed
against the panel of the door so that it could not be opened from the
outside.
That ingress to this passage might not be prevented by the
bolting of the door by the President and his party after entering, the
screws of the fastenings had been drawn, so that it could be easily
pushed open. A hole had been bored through the door to the box,
opposite where the President's chair was placed, with a small bit,
and reamed out with a knife, so that Booth could, after gaining the
passage and barring the door behind him, peep through this hole
and assure himself of the exact position of his intended victim. The
manner in which all of these arrangements had been made, the
mortise in the plastered wall, the bar of wood fitted to the mortise,
and in length having been exactly prepared to fit against the panel
of the door and act as a brace, show that all these preparations had
been made with the greatest forethought and care.
About three weeks previous to the assassination, John H.
Surratt, Herold, and Atzerodt brought to the tavern at Surrattsville,
in Maryland, about ten miles below Washington City, owned by Mrs.
Surratt, and at the time occupied by a man by the name of Lloyd,
two carbines, with ammunition, a monkey-wrench, and a piece of
rope. Surratt asked Lloyd to take charge of these things and keep
them secreted, saying they would be called for before a great while,
at the same time showing him a suitable place about the house in
which to hide them. The Surratt family had lived in this house and
kept a country tavern until within a few months previous, when they
had removed to Washington, renting their tavern to Lloyd, so that
Surratt was much more familiar with the house than Lloyd. These
things, as we shall see, were placed there for the use of Booth and
his companion in their flight after the assassination. As a
precautionary measure, Booth, on the Tuesday before the
assassination, sought an interview with Mrs. Surratt, who shortly
after that interview discovered that she had some private business at
Surrattsville that had to be attended to that day, and so she asked
Mr. Wiechmann, a young man who had been a boarder at her house
for several months, to drive her down, saying that she wanted to go
and see a Mr. Nothey who owed her some money. She then sent
Wiechmann to Booth, to get his horse and buggy for the drive.
Booth told Wiechmann that he had sold his horse and buggy, but
gave him ten dollars with which to procure one. Meeting Lloyd on
the way down, driving up to Washington, they stopped; Lloyd got
out of his buggy and went to the side of Mrs. Surratt's buggy, on
which she was sitting, when Mrs. Surratt told Lloyd, as he afterwards
testified, in a low voice, so that Wiechmann did not hear what she
said, to have those shooting irons ready, or handy, as they would be
called for before long. On the day of the assassination Booth again
had a private interview with Mrs. Surratt, after which she again
asked Wiechmann to drive her down to Surrattsville, claiming the
same errand as before. On this occasion she sought an opportunity
for a private interview with Lloyd, when she told him to have the
carbines handy, as they would be called for that night, at the same
time handing him a field-glass, which Booth had given to her, and
telling him to have two bottles of whiskey ready.
John H. Surratt left Washington for Richmond on the 25th of
March and returned to Washington on the 3d of April, leaving for
Montreal on the evening of the same day. He showed to Wiechmann
—an old college friend and, at this time, a boarder in his mother's
house—nine or eleven twenty-dollar gold pieces, and sixty dollars in
greenbacks, on his return from Richmond. Surratt, in his Rockville
lecture, admits that he received two hundred dollars in gold from
Benjamin to pay expenses and remunerate for services. Surratt left
Washington for Canada on the evening of the 3d of April, and we
find him, by the evidence, in Montreal on the 6th, where he
delivered to Thompson a cipher dispatch from Jefferson Davis, and a
letter from Mr. Benjamin, of Davis's Richmond Cabinet. After reading
these documents, Thompson, laying his hand on them, said, "This
makes the thing all right." The sanction of the rebel president to his
arrangements with the assassins had been obtained, and authority
also for the expenditure of funds to fulfil the contract. The Canada
conspirators who were to take a part prepared at once, and started
for the States, boasting to their friends that they would hear of the
death of Old Abe and others before ten days. This was on the 8th of
April, and nothing now remained but to find, and use, an
opportunity; and Booth selected the appearance of the President at
the theatre as affording the opportunity he sought, and proceeded
to make all his arrangements accordingly.
All things were now ready. Booth had selected the route for his
escape and had provided to be furnished with a field-glass, two
carbines, and two bottles of whiskey at Surrattsville, having sent a
notice to Lloyd to have them ready, as they would be called for that
night. He had provided horses from a livery-stable for himself and
Herold, who was to accompany him. He had also provided a horse
for Payne, whose part was to murder Secretary Seward. He had
assembled his assistants in Washington, to one of whom, Michael
O'Laughlin, he had assigned the task of the assassination of General
Grant; and having made these preparations, he spent the day and
afternoon of the 14th of April looking after the matter generally, and
keeping up his courage, or rather recklessness, with frequent
potations of whiskey. To Payne he had given a one-eyed bay horse,
which he had purchased of a man by the name of Gardner, a
neighbor of Dr. Samuel Mudd, in Charles County, Maryland. Mudd
accompanied him, and introduced him to Gardner as a man who was
desirous of purchasing land in that part of Maryland, and who
wished a good driving horse that he could use for a short time.
During the afternoon of the 14th, Booth, Herold, and Atzerodt hired
horses from liverymen, and were to be seen riding here and there
about the streets of Washington, frequently stopping at saloons to
refresh themselves with that which obtunds all moral sensibility and
makes men reckless in wickedness. Booth was acting the part of a
general mustering his forces for the conflict, part of which he thus
displayed openly, but keeping another part in concealment. He kept
himself in active communication with all, and delivered his orders
and instructions. Feeling the full force of the responsibility of his
engagement, and earnestly intent on its complete and thorough
accomplishment, he attended in person to every detail to make
failure, if possible, an impossibility.
It would seem that a previous attempt had been made to
assassinate the President, which had resulted in a failure. It was
known that President Lincoln was in the habit of riding out to the
Soldiers' Home of evenings, passing through a lonely suburb of the
city unguarded. Some time in March, John Wilkes Booth, John H.
Surratt, Payne, Atzerodt, Herold, and two others, left the house of
Mrs. Surratt about two o'clock in the afternoon, on horseback,
armed with revolvers and bowie-knives, and returned about six
o'clock under the greatest possible excitement of rage and
disappointment. All the evidence went to show that this expedition
was regarded by them as one of the greatest importance, involving
the necessity of leaving the city, perhaps for good, as their return in
the evening was as much of a surprise to their friends as it was an
occasion of dissatisfaction to themselves. I think there can hardly be
a doubt that they expected to intercept the President on his way to
the Home, and were lying in wait for him with the purpose of there
assassinating him, and then making their escape. The President,
however, upon the earnest advice of his cabinet, had yielded the
point of riding unprotected and alone, and had accepted the
protection of an escort of cavalry on these rides. Booth and his party
finding him thus guarded had been compelled to abandon the idea
of thus finding an opportunity to assassinate him, and so had to
prepare a new plan of operations. There was a rumor, which found
its way into the papers about this time, that there was a plot to
capture the President and carry him a prisoner to Richmond; but
however much Booth's pride and vanity might have impelled him to
achieve the notoriety that would have attended the accomplishment
of such a feat, the difficulties and dangers attending its
accomplishment must have been too obvious to a man of Booth's
sagacity, and its success involved in too much uncertainty, to have
justified him in making such an attempt.
In view of all the facts, I conclude that the real purpose of Booth
and his party on the occasion referred to was to murder the
President, and trust to flight for concealment and safety. But now
Booth was fully possessed with the idea of the practicability of his
present plan, and was determined to know no such word as fail; and
that it was entirely possible that, but for a Providential interference,
he might have made good his escape after murdering the President,
we shall hereafter see.
President Lincoln had been convinced by the most undoubted
proofs that a plan for his assassination at Baltimore whilst on his
way to Washington, in 1861, to assume the responsibilities of the
office to which he had been called by the choice of the people, had
been arranged and prepared for by his enemies, and had only been
prevented of its execution by the strategic movement planned by his
friends, by which he passed through that city during the night
previous to the morning on which he was expected.
"From the very beginning of his Presidency Mr. Lincoln had been
constantly subject to the threats of his enemies and the warnings of
his friends. The threats came in every form: his mail was infested
with brutal and vulgar menace, mostly anonymous, the proper
expression of vile and cowardly minds.
"The warnings were not less numerous; the vaporings of village
bullies, the extravagancies of excited secessionist politicians, even
the drolling of practical jokers, were faithfully reported to him by
zealous or nervous friends. Most of these communications received
no notice. In cases where there seemed a ground for inquiry it was
made, as carefully as possible, by the President's private secretary
and by the War Department, but always without substantial results.
"Warnings that appeared to be most definite, when they came to
be examined proved too vague and confused for further attention.
The President was too intelligent not to know he was in some
danger. Madmen frequently made their way to the very door of the
executive offices, and sometimes into Mr. Lincoln's presence.
"He had himself so sane a mind, and a heart so kindly even to
his enemies, that it was hard for him to believe in a political hatred
so deadly as to lead to murder. He would sometimes laughingly say,
'Our friends on the other side would make nothing by exchanging
me for Hamlin,' the Vice-President having the reputation of more
radical views than his chief. He knew, indeed, that incitements to
murder him were not uncommon in the South. An advertisement had
appeared in a paper of Selma, Alabama, in December, 1864, opening
a subscription for funds to affect the assassination of Lincoln,
Seward, and Johnson before the inauguration."1
In view of all this danger he would say "that he could not
possibly guard against it unless he were to shut himself up in an iron
box, in which condition he could scarcely perform the duties of a
President. By the hand of a murderer he could only die once; to go
continually in fear would be to die over and over."
To his faithful and devoted friend, Father Chiniquy, who on
several occasions warned him of his danger, and of the ultimate
source of its inspiration, he said, "I see no other way than to be
always prepared to die. I know my danger; but man must not care
how and where he dies, provided he dies at the post of honor and
duty."
We have come to the point now where we find, on the part of
his murderers, all things ready for his taking off; and their intended
victim prepared in mind for his fate, and ready to "die at the post of
honor and duty." What a fearful, and at the same time, sublime
spectacle! The powers of light and the powers of darkness were
contending, as ever, for the supremacy. Satan, the usurper, claims
this world for his kingdom. He has seduced and enslaved the human
race, and, by every false and cunning device, is always resisting
every movement that looks to the disenthralment of mankind, and
bringing the world back to its allegiance to God, its rightful
sovereign. How sublime was the faith of President Lincoln in the
ultimate triumph of the right! How sincerely and believingly could he
have sung,
"Thy saints in all this glorious war,
Shall conquer though they die;
They see the triumph from afar,
By faith they bring it nigh."
CHAPTER III.

ASSASSINATION OF THE PRESIDENT


AND ATTEMPTED ASSASSINATION
OF SECRETARY SEWARD.

On the morning of the 14th of April, 1865, the President's


messenger went to Ford's Theatre in Washington City and engaged a
private box for the President and General Grant, with their wives, to
witness the play of "Our American Cousin," which was to be
rendered there that night. The heavy burden of responsibility, the
weight of cares and anxieties which had for four long years rested
on the head of President Lincoln in his official position of President
of the United States and Commander-in-Chief of its army and navy,
employed during all that time in suppressing a gigantic rebellion of
the slave-holding States of the South against the constitutional and
lawful authority of the government, and which had followed him into
his second term of office, upon which he had just entered, had been
partially lifted by the signal success of the Union arms at
Appomattox, and the surrender of Lee's army. General Grant, who
had just accepted the unconditional surrender of that army, and
finished the work of dismissing to their homes the officers and men
who had composed it (and who for four long years had fought with
such magnificent bravery, and manifested such earnestness and
determinedness of purpose in a cause which, though bad, was no
doubt esteemed by them to be just), under no other condition than
that they should return to their homes and the pursuits of peaceful
life, and desist from all further acts of hostility against the
government they had sought, but failed, to overthrow, had gone to
Washington to talk over the situation with the President and
Secretary of War, and to decide on future operations for the speedy
establishment of peace. With the surrender of Lee's army, and the
successful march of Sherman from Atlanta to the sea, and his almost
unresisted progress up the coast toward the Nation's Capital, it was
obvious that the rebellion had collapsed, and that the return of
peace was just at hand. All loyal hearts throughout the land
throbbed with joy, and praise and thanksgiving ascended to Him
who had stamped the righteousness of the union cause with the
signet of His approbation, in thus giving us the victory after a long
and bloody contest. The years of sacrifice, toil, suffering and danger
were almost forgotten in the gladness of that hour; and the war-
scarred veterans in the field, and their friends at home, were
rejoicing at the prospect of a speedy re-union, under skies of peace.
It was an hour big with the memories of the past and hopes of the
future. When we think of what President Lincoln had endured
through all these years of the war; of his unfaltering purpose to
discharge all the duties of his official oath, by protecting, defending
and preserving the constitution of his country; of the formidable
difficulties that had to be met and overcome—difficulties thrown
across his pathway often by friends, always by foes; when we
remember his largeness of soul, his unbounded love of, and
sympathy with, mankind; his all controlling love of his country and
her institutions of freedom; his patient toleration of opposing views
of martial and of political policy; his self-poise, and almost infallible
appreciation of the situation and its demands, in whatever
circumstances he might be placed; his kindness of nature and
goodness of heart, we can well conceive what must have been his
fullness of joy on this the last day of his sojourn on earth. God, in his
providence, led him to the opening of a vista through which his
patriotic and philanthropic soul could swell with delightful
anticipations of the greatness, the glory, and the happiness that
should accrue to mankind through his faithfulness to the obligations
of his official oath, by which he had vindicated his authority, and
brought to a right solution the great moral question underlying the
contest, and thus had made our beloved land a land of freedom in
fact, as well as in name. He saw a new and glorious era about to
dawn on his country. Like Moses, however, he was only permitted, in
vision, to look over into the promised land—the great future of his
beloved country.
It is consoling to thus know that to the great Lincoln his last day
on earth was the happiest, and at the same time, the meekest day
of his life. His biographers, Nicolay and Hay, who were able to write
from personal association with, and observation of, this great man,
inform us that on this day his soul was filled with the kindliest
feelings toward his enemies, and in his last conference with his
cabinet his policy of dealing with them was shadowed forth as free
from feelings of revenge or desire for the punishment of any. He
desired that no man should lose his life for the part he had taken in
the rebellion. He held "malice toward none," and was filled with
"charity for all." His passage from time to eternity, though brought
about by the bullet of an assassin, was a passage through a
triumphal arch, whose further portal was the gate of heaven.
The presence of General Grant was known to the city, and it was
noised abroad that both he and President Lincoln would honor the
theatre with their presence on that evening. The public knowledge
of this fact was calculated to bring out a brilliant and large
assemblage of people. The loyal citizens would be there to give to
the President and the successful and popular commander of his
armies in the field a heartfelt and royal ovation in this the hour of
their triumph. All felt happy and secure. That they were coming
together to witness, on that night, the awful tragedy of the
assassination of the nation's head, President Lincoln, was not
dreamed of by any except those who had made every preparation in
advance for accomplishing the murderous plot, and who were
stealthily slipping about through the assembling crowds, like fiends,
to assure themselves that every arrangement for the successful
accomplishment of their hellish purpose was complete. During the
day General Grant received a telegram that called him to
Philadelphia on business, and owing to this apparently providential
circumstance he was prevented from accompanying the President to
the theatre on that eventful night, and also, in all probability, from
being, with the President, a victim of the plot, in which there is good
reason to conclude, from all the evidence, his life was included, and
that for him an assassin had been provided.
In lieu of General and Mrs. Grant, President Lincoln had taken
Major Rathbone and Miss Harris, the step-son and daughter of
Senator Harris, of New York, into the Presidential party. On reaching
the theatre at a somewhat late hour, and after the play had
commenced, as soon as the presence of the President became
known, the actors stopped playing, the band struck up "Hail to the
Chief," and the audience rose and received him with vociferous
cheering.
The party proceeded along the rear of the dress circle, and
entered the box that had been prepared for them, the President
taking the rocking chair that had been placed there for him on the
left of the box, and nearest to the audience, about four feet from the
door of entrance to the box. Major Rathbone and the ladies found
seats on the President's right. During this time the conspirators were
on the alert, scanning the situation, passing about so as to keep up
a communication with each other, in preparation for their work.
Booth had arranged with Payne to assassinate Secretary Seward at
the same time that he would assassinate the President; and no
doubt had planned for Payne, after accomplishing his task, to join
him and Herold in their flight, crossing the Eastern Branch at the
Navy Yard bridge, and then to pass down through Maryland and
cross the Potomac, at a selected point, into Virginia, where they
might consider themselves as being safe amongst their friends.
Secretary Seward was known to have received severe injuries from
the upsetting of his carriage, and to be lying in a critical condition
under the care of Dr. Verdi. Booth had planned to take advantage of
this circumstance for gaining admittance for Payne into the sick
chamber, where, by springing with the ferocity of a tiger upon the
sick man, he might make quick work in dispatching him with his
dagger. To this end he had prepared a package rolled up in paper,
and had schooled Payne in the artifice, teaching him to represent
himself as having been sent by Dr. Verdi with this package of
medicine, which it was necessary he should deliver in person, as he
had important verbal directions as to the manner of its use, which
required him to see the Secretary.
About ten o'clock Booth rode up the alley back of the theatre
where he had been accustomed to keep his horse, and having
reached the rear entrance, called for Ned three times, each time a
little louder than before. At the third call Ned Spangler answered to
his summons by appearing at the door. Booth's first salutation was in
the form of a question: "Ned, you will help me all you can, won't
you?" To which Spangler replied, "Oh, yes!" Booth then requested
him to send "Peanuts" (a boy employed about the theatre), to hold
his horse. Spangler gave the boy orders to do this, and upon the boy
making the objection that he might be out of place at the time he
had a duty to perform, Spangler bade him go, saying that he would
stand responsible for him. The boy then took the reins, and held the
horse for about half an hour, until Booth returned to reward him with
a curse and a kick, as he jerked the rein from him preparatory to
remounting for his flight. After entering the theatre, Booth passed
rapidly across the stage, glancing at the box occupied by his
intended victim, and looking up his accomplices, he passed out of
the front door on to the walk where he was met by two of his fellow
conspirators. One of these was a low, villainous-looking fellow, whilst
the other was a very neatly-dressed man. Booth held a private
conference with these by the door where he and the vulgar-looking
fellow had stationed themselves. The neatly-dressed man crossed
the walk to the rear of the President's carriage and peeped into it.
One of the witnesses, who was sitting on the platform in front of the
theatre, had his attention arrested by the manner and conduct of
these men, and so watched them very closely.
It was at the close of the second act that Booth and his two
fellow conspirators appeared at the door. Booth said, "I think he will
come down now"; and they aligned themselves to await his coming.
Their communications with each other were in whispered tones.
Finding that the President would remain until the close of the play,
they then began to prepare to assassinate him in the theatre. The
neatly-dressed man called the time three times in succession at
short intervals, each time a little louder than before. Booth now
entered the saloon, took a drink of whiskey, and then went at once
into the theatre. He passed quickly along next to the wall behind the
chairs, and having reached a point near the door that led to the
passage behind the box, he stopped, took a small pack of visiting
cards from his pocket, selected one and replaced the others; stood a
second with it in his hand, and then showed it to the President's
messenger, who was sitting just below him, and then, without
waiting, passed through the door from the lobby into the passage,
closing and barring it after him. Taking a hasty, but careful, look
through the hole which he had had made in the door for the purpose
of assuring himself of the President's position, and cocking his pistol
and with his finger on the trigger, he pulled open the door, and
stealthily entered the box, where he stood right behind and within
three feet of the President. The play had advanced to the second
scene of the third act, and whilst the audience was intensely
interested Booth fired the fatal shot—the ball penetrating the skull
on the back of the left side of the head, inflicting a wound in the
brain (the ball passing entirely through and lodging behind the right
eye), of which he died at about half-past seven o'clock on the
morning of the fifteenth. He was unconscious from the moment he
was struck until his spirit passed from earth. An unspeakable calm
settled on that remarkable face, leaving the impress of a happy soul
on the casket it had left behind.
Thus died the man who said, "Senator Douglass says he don't
care whether slavery is voted up, or voted down; but God cares, and
humanity cares, and I care."
As soon as Booth had fired his pistol, and was satisfied that his
end was accomplished, he cried out, "Revenge for the South!" and
throwing his pistol down, he took his dagger in his right hand, and
placed his left hand on the balustrade preparatory to his leap of
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!

ebookname.com

You might also like