WebDriver that Won't Drive You Crazy

WebDriver that Won't Drive You Crazy

Workshop for StarEast and Romainian Testing Conference

Fd80f9c58b06270d42356dd77a32defa?s=128

Jim Holmes

April 30, 2018
Tweet

Transcript

  1. WebDriver That Won’t Drive You Crazy

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

  3. Jim Holmes jim@GuidePostSystems.com github.com/jimholmes @aJimHolmes

  4. Logistics

  5. Time Exercises Breaks Backlog

  6. Disclaimers

  7. I’m not an expert

  8. I’m “seasoned”

  9. My workshops are collaborative

  10. Stuff WILL Break

  11. Goals

  12. There Are No “Best Practices”

  13. Know the fundamentals

  14. Test the right things

  15. Get the right coverage

  16. Write good code

  17. You

  18. What are Two Things you hope to learn?

  19. Opening Exercises

  20. What does “Quality” mean to you?

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

  22. Thanks to Karen Greaves and Samantha Laing A Coach’s Guide

    to Agile Testing https://leanpub.com/AgileTesting
  23. What’s Our Job?

  24. Who guarantees “quality” ??

  25. Risk

  26. Value

  27. Risk and Value guide all our tests. ESPECIALLY WebDriver tests

  28. Types of Testing

  29. “test” versus “check”

  30. Any failure is a starting point

  31. Unit Tests

  32. 40 hours TIMES $20 per hour EQUALS $800

  33. Integration (or Service) Tests

  34. Using Postman When I call the create item web service

    with a new item service template Then the item shows up in the database
  35. User Interface (or end-to-end)

  36. (NOT “just” testing of JavaScript in browser)

  37. 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
  38. Exploratory Testing

  39. 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
  40. https://martinfowler.com/articles/practical-test-pyramid.html

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

  42. Box of rocks

  43. There are no ‘best practices’ There is no ‘one testing

    ring to rule them all’
  44. Security Accessibility Scalability Performance Usability Compliance Mom

  45. Demo What it looks like running together

  46. Working With Risk

  47. Setup

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

  49. None
  50. First run in Eclipse

  51. First run in Visual Studio

  52. Overview

  53. Components WebDriver APIs Drivers Frameworks Libraries Tools

  54. Browser

  55. Browser WebDriver

  56. Browser WebDriver

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

  58. WebDriver Bindings Support Classes .NET Java Ruby Python JavaScript Perl

    blah blah blah blah WebDriverWait ExpectedConditions etc. +
  59. Host System Browser WebDriver Bindings + support classes

  60. Host System Browser WebDriver Bindings + support classes Driver ChromeDriver,

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

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

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

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

    eg
  65. Host System Browser WebDriver

  66. Host System Browser WebDriver Driver

  67. Host System Browser WebDriver Driver Remote WebDriver

  68. Host System Browser WebDriver Driver Remote WebDriver

  69. Host System Browser WebDriver Driver Remote WebDriver

  70. Host System Browser WebDriver Driver Remote WebDriver

  71. Host System Browser WebDriver Driver Remote WebDriver

  72. Host System Browser WebDriver Driver Remote WebDriver

  73. Host System Browser WebDriver Driver Remote WebDriver

  74. Host System WebDriver Selenium Server or Grid Host System Browser

    Driver Remote WebDriver
  75. Host System Browser Driver Remote WebDriver Test Framework WebDriver Selenium

    Server or Grid
  76. Assert.IsNotNullOrEmpty( grid.FindElement( By.CssSelector(SOME_ELEMENT)).Text);

  77. Test Framework Browser WebDriver Driver

  78. Language Framework Test Framework Browser WebDriver Driver

  79. GIVEN I am logged on as a Salesperson WHEN I

    create a new lead THEN that contact appears only in my leads
  80. Maintainability

  81. Your Test Suite should NOT BE

  82. “flaky”

  83. Require lots of time to change or fix

  84. Your Test Suite SHOULD BE

  85. Valuable

  86. Reliable

  87. Trustworthy

  88. Easy to Change

  89. How to get there

  90. Team With the Developers

  91. Small Steps

  92. Think Before You Code

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

  94. Refactor

  95. Code can be like poetry

  96. Think Plan Fail Learn Fail Less

  97. WebDriver 101

  98. The Basics

  99. Test Layout: Arrange Act Assert

  100. Test One Thing

  101. Locators

  102. IDs CSS Selectors XPath

  103. Async

  104. What is Async?

  105. How do we avoid it driving us insane?

  106. Write the First Test

  107. Is the Grid there?

  108. Refactor

  109. Setup / Teardown

  110. Refactor Again

  111. Page Objects Know the page Not the test

  112. Clean Tests Know the test Not the page

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

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

  115. More Advanced Concepts

  116. Understand Coverage

  117. What Tests Do We Need?

  118. Walkthrough: Unit and Integration

  119. Backing APIs

  120. Use Helper Libraries

  121. Team With the Developers

  122. Test Data Setup

  123. Testable Systems

  124. Own the System Code? USE THAT POWER!

  125. Hack the UI

  126. Locators Custom IDs

  127. Async flags

  128. Better Tests

  129. Hack the System

  130. Feature Toggles Mock Services

  131. Better Tests

  132. Now What?

  133. Factories Configuration Lifecycle Management

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

  135. CI/CD

  136. Cloud

  137. Discussion: Parameterizing for Different Envs

  138. Parallel

  139. None
  140. Parallelization Solves Everything!

  141. Parallelization Solves Everything!

  142. None
  143. Parallelization Solves Everything!

  144. Fix Your Dang System!

  145. bit.ly/3HoursTo3Mins

  146. Discussion: Test Stability in Parallel Execution

  147. Takeaways

  148. None
  149. Automate High-Value, High Risk

  150. Avoid Overlapping Coverage

  151. Test Code is Production Code

  152. Manage Your Data

  153. Build Out APIs

  154. Avoid End-To-End

  155. Parallelization as LAST RESORT

  156. bit.ly/leadershipjourney

  157. A Couple Closing Remarks

  158. 0) No SharePoint

  159. B) Hug your loved ones RIGHT NOW

  160. THANK YOU