Slide 1

Slide 1 text

WebDriver That Won’t Drive You Crazy

Slide 2

Slide 2 text

Get Latest Slides At http://speakerdeck.com/ jimholmes

Slide 3

Slide 3 text

Jim Holmes [email protected] github.com/jimholmes @aJimHolmes

Slide 4

Slide 4 text

Logistics

Slide 5

Slide 5 text

Time Exercises Breaks Backlog

Slide 6

Slide 6 text

Disclaimers

Slide 7

Slide 7 text

I’m not an expert

Slide 8

Slide 8 text

I’m “seasoned”

Slide 9

Slide 9 text

My workshops are collaborative

Slide 10

Slide 10 text

Stuff WILL Break

Slide 11

Slide 11 text

Goals

Slide 12

Slide 12 text

There Are No “Best Practices”

Slide 13

Slide 13 text

Know the fundamentals

Slide 14

Slide 14 text

Test the right things

Slide 15

Slide 15 text

Get the right coverage

Slide 16

Slide 16 text

Write good code

Slide 17

Slide 17 text

You

Slide 18

Slide 18 text

What are Two Things you hope to learn?

Slide 19

Slide 19 text

Opening Exercises

Slide 20

Slide 20 text

What does “Quality” mean to you?

Slide 21

Slide 21 text

If Testing were a sport, what sport would it be?

Slide 22

Slide 22 text

Thanks to Karen Greaves and Samantha Laing A Coach’s Guide to Agile Testing https://leanpub.com/AgileTesting

Slide 23

Slide 23 text

What’s Our Job?

Slide 24

Slide 24 text

Who guarantees “quality” ??

Slide 25

Slide 25 text

Risk

Slide 26

Slide 26 text

Value

Slide 27

Slide 27 text

Risk and Value guide all our tests. ESPECIALLY WebDriver tests

Slide 28

Slide 28 text

Types of Testing

Slide 29

Slide 29 text

“test” versus “check”

Slide 30

Slide 30 text

Any failure is a starting point

Slide 31

Slide 31 text

Unit Tests

Slide 32

Slide 32 text

40 hours TIMES $20 per hour EQUALS $800

Slide 33

Slide 33 text

Integration (or Service) Tests

Slide 34

Slide 34 text

Using Postman When I call the create item web service with a new item service template Then the item shows up in the database

Slide 35

Slide 35 text

User Interface (or end-to-end)

Slide 36

Slide 36 text

(NOT “just” testing of JavaScript in browser)

Slide 37

Slide 37 text

Using any of our supported browsers And I don’t have anything in my cart When I add bacon, tires, and a frog to my cart Then I will see those items in my cart

Slide 38

Slide 38 text

Exploratory Testing

Slide 39

Slide 39 text

Using SQL Injection, malformed data, and oversized data I’m going to explore the search product screens For 45 minutes To see what interesting (and scary!) stuff I can find

Slide 40

Slide 40 text

https://martinfowler.com/articles/practical-test-pyramid.html

Slide 41

Slide 41 text

https://twitter.com/noahsussman/status/836612175707930625

Slide 42

Slide 42 text

Box of rocks

Slide 43

Slide 43 text

There are no ‘best practices’ There is no ‘one testing ring to rule them all’

Slide 44

Slide 44 text

Security Accessibility Scalability Performance Usability Compliance Mom

Slide 45

Slide 45 text

Demo What it looks like running together

Slide 46

Slide 46 text

Working With Risk

Slide 47

Slide 47 text

Setup

Slide 48

Slide 48 text

Repository https://github.com/ jimholmes/ SaneWebDriver-CSharp SaneWebDriver-Java

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

First run in Eclipse

Slide 51

Slide 51 text

First run in Visual Studio

Slide 52

Slide 52 text

Overview

Slide 53

Slide 53 text

Components WebDriver APIs Drivers Frameworks Libraries Tools

Slide 54

Slide 54 text

Browser

Slide 55

Slide 55 text

Browser WebDriver

Slide 56

Slide 56 text

Browser WebDriver

Slide 57

Slide 57 text

IWebDriver browser = new FirefoxDriver(); browser.Navigate().GoToUrl(“SOMEPLACE”);

Slide 58

Slide 58 text

WebDriver Bindings Support Classes .NET Java Ruby Python JavaScript Perl blah blah blah blah WebDriverWait ExpectedConditions etc. +

Slide 59

Slide 59 text

Host System Browser WebDriver Bindings + support classes

Slide 60

Slide 60 text

Host System Browser WebDriver Bindings + support classes Driver ChromeDriver, eg

Slide 61

Slide 61 text

Host System Browser WebDriver Bindings + support classes Driver ChromeDriver, eg

Slide 62

Slide 62 text

Host System Browser WebDriver Bindings + support classes Driver ChromeDriver, eg

Slide 63

Slide 63 text

Host System Browser WebDriver Bindings + support classes Driver ChromeDriver, eg

Slide 64

Slide 64 text

Host System Browser WebDriver Bindings + support classes Driver ChromeDriver, eg

Slide 65

Slide 65 text

Host System Browser WebDriver

Slide 66

Slide 66 text

Host System Browser WebDriver Driver

Slide 67

Slide 67 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 68

Slide 68 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 69

Slide 69 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 70

Slide 70 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 71

Slide 71 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 72

Slide 72 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 73

Slide 73 text

Host System Browser WebDriver Driver Remote WebDriver

Slide 74

Slide 74 text

Host System WebDriver Selenium Server or Grid Host System Browser Driver Remote WebDriver

Slide 75

Slide 75 text

Host System Browser Driver Remote WebDriver Test Framework WebDriver Selenium Server or Grid

Slide 76

Slide 76 text

Assert.IsNotNullOrEmpty( grid.FindElement( By.CssSelector(SOME_ELEMENT)).Text);

Slide 77

Slide 77 text

Test Framework Browser WebDriver Driver

Slide 78

Slide 78 text

Language Framework Test Framework Browser WebDriver Driver

Slide 79

Slide 79 text

GIVEN I am logged on as a Salesperson WHEN I create a new lead THEN that contact appears only in my leads

Slide 80

Slide 80 text

Maintainability

Slide 81

Slide 81 text

Your Test Suite should NOT BE

Slide 82

Slide 82 text

“flaky”

Slide 83

Slide 83 text

Require lots of time to change or fix

Slide 84

Slide 84 text

Your Test Suite SHOULD BE

Slide 85

Slide 85 text

Valuable

Slide 86

Slide 86 text

Reliable

Slide 87

Slide 87 text

Trustworthy

Slide 88

Slide 88 text

Easy to Change

Slide 89

Slide 89 text

How to get there

Slide 90

Slide 90 text

Team With the Developers

Slide 91

Slide 91 text

Small Steps

Slide 92

Slide 92 text

Think Before You Code

Slide 93

Slide 93 text

The best code you write is that which you don’t

Slide 94

Slide 94 text

Refactor

Slide 95

Slide 95 text

Code can be like poetry

Slide 96

Slide 96 text

Think Plan Fail Learn Fail Less

Slide 97

Slide 97 text

WebDriver 101

Slide 98

Slide 98 text

The Basics

Slide 99

Slide 99 text

Test Layout: Arrange Act Assert

Slide 100

Slide 100 text

Test One Thing

Slide 101

Slide 101 text

Locators

Slide 102

Slide 102 text

IDs CSS Selectors XPath

Slide 103

Slide 103 text

Async

Slide 104

Slide 104 text

What is Async?

Slide 105

Slide 105 text

How do we avoid it driving us insane?

Slide 106

Slide 106 text

Write the First Test

Slide 107

Slide 107 text

Is the Grid there?

Slide 108

Slide 108 text

Refactor

Slide 109

Slide 109 text

Setup / Teardown

Slide 110

Slide 110 text

Refactor Again

Slide 111

Slide 111 text

Page Objects Know the page Not the test

Slide 112

Slide 112 text

Clean Tests Know the test Not the page

Slide 113

Slide 113 text

SRP Test/do one thing (and do it well)

Slide 114

Slide 114 text

DRY/moist Don’t Repeat Yourself (except where it makes sense)

Slide 115

Slide 115 text

More Advanced Concepts

Slide 116

Slide 116 text

Understand Coverage

Slide 117

Slide 117 text

What Tests Do We Need?

Slide 118

Slide 118 text

Walkthrough: Unit and Integration

Slide 119

Slide 119 text

Backing APIs

Slide 120

Slide 120 text

Use Helper Libraries

Slide 121

Slide 121 text

Team With the Developers

Slide 122

Slide 122 text

Test Data Setup

Slide 123

Slide 123 text

Testable Systems

Slide 124

Slide 124 text

Own the System Code? USE THAT POWER!

Slide 125

Slide 125 text

Hack the UI

Slide 126

Slide 126 text

Locators Custom IDs

Slide 127

Slide 127 text

Async flags

Slide 128

Slide 128 text

Better Tests

Slide 129

Slide 129 text

Hack the System

Slide 130

Slide 130 text

Feature Toggles Mock Services

Slide 131

Slide 131 text

Better Tests

Slide 132

Slide 132 text

Now What?

Slide 133

Slide 133 text

Factories Configuration Lifecycle Management

Slide 134

Slide 134 text

https://thefriendlytester.co.uk/2014/02/webdriver-factory.html

Slide 135

Slide 135 text

CI/CD

Slide 136

Slide 136 text

Cloud

Slide 137

Slide 137 text

Discussion: Parameterizing for Different Envs

Slide 138

Slide 138 text

Parallel

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

Parallelization Solves Everything!

Slide 141

Slide 141 text

Parallelization Solves Everything!

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

Parallelization Solves Everything!

Slide 144

Slide 144 text

Fix Your Dang System!

Slide 145

Slide 145 text

bit.ly/3HoursTo3Mins

Slide 146

Slide 146 text

Discussion: Test Stability in Parallel Execution

Slide 147

Slide 147 text

Takeaways

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

Automate High-Value, High Risk

Slide 150

Slide 150 text

Avoid Overlapping Coverage

Slide 151

Slide 151 text

Test Code is Production Code

Slide 152

Slide 152 text

Manage Your Data

Slide 153

Slide 153 text

Build Out APIs

Slide 154

Slide 154 text

Avoid End-To-End

Slide 155

Slide 155 text

Parallelization as LAST RESORT

Slide 156

Slide 156 text

bit.ly/leadershipjourney

Slide 157

Slide 157 text

A Couple Closing Remarks

Slide 158

Slide 158 text

0) No SharePoint

Slide 159

Slide 159 text

B) Hug your loved ones RIGHT NOW

Slide 160

Slide 160 text

THANK YOU