Skip to Content
Selenium Design Patterns and Best Practices

Selenium Design Patterns and Best Practices

Kovalenko, Dima

Selenium WebDriver is a global leader in automated web testing. It empowers users to perform complex testing scenarios with its simple and powerful interface. This guide will provide you with all the skills you need to successfully create a functional Selenium test suite. Starting from the very beginning of the Selenium IDE, this book will show you how to transition into a real programing language such as Ruby or Java. You will quickly learn how to improve your code quality with refactoring and the skills needed to plan for the future development of your website to future-proof your test suite. With ample test examples running against a life-like e-commerce store and detailed step-by-step code review and explanations, you will be ready to test any challenge web developers might throw your way. This book is intended for anyone who wants to create a test suite that is easy to maintain by expanding your knowledge until you feel truly confident and comfortable with Selenium

eBook, Electronic resource, Book. English. Electronic books.
Published Packt Publishing 2014
Rate this

This resource is available electronically from the following locations

Details

ISBN: 1322152977, 1783982713, 9781322152974, 9781783982707, 9781783982714
Note: Print version record.
Language note: English.
Physical Description: 1 online resource
Series: Community Experience Distilled
Subject: Application software Testing.; COMPUTERS Software Development & Engineering General.; Web site development.; COMPUTERS Programming Open Source.; COMPUTERS Software Development & Engineering Tools.; Scripting languages (Computer science)
Series Title: Community experience distilled.
Local note: eBooks on EBSCOhost EBSCO eBooks for FE Collection (UK)

Contents

  1. Cover
  2. Copyright
  3. Credits
  4. Foreword
  5. About the Author
  6. Acknowledgments
  7. About the Reviewers
  8. www.PacktPub.com
  9. Table of Contents
  10. Preface
  11. Chapter 1: Writing the First Test
  12. Choosing Selenium over other tools
  13. Right tool for the right job
  14. Price
  15. Open source
  16. Flexibility
  17. The Record and Playback pattern
  18. Advantages of the Record and Playback pattern
  19. Disadvantages of the Record and Playback pattern
  20. Getting started with the Selenium IDE
  21. Installing the Selenium IDE
  22. Recording our first test
  23. Saving the test
  24. Understanding Selenium commands
  25. Reading Selenese
  26. Comparing Ruby to Selenese.
  27. Comparing Selenium commands in multiple languagesWriting a Selenium test in Ruby
  28. Introducing Test::Unit
  29. Introducing asserts
  30. Interactive test debugging
  31. Summary
  32. Chapter 2: The Spaghetti Pattern
  33. Introducing the Spaghetti pattern
  34. Advantages of the Spaghetti pattern
  35. Disadvantages of the Spaghetti pattern
  36. Testing the product review functionality
  37. Starting a product review test
  38. Locating elements on the page
  39. Using a browser''s element inspector
  40. Introducing locator strategies
  41. Using advanced locator strategies
  42. Writing locator strategy code
  43. Using chained selector strategy methods.
  44. Using the CSS selectorUsing XPath
  45. Implementing clicks and assertions
  46. Duplicating the product review test
  47. Reasons for failures
  48. The Chain Linked pattern
  49. The Big Ball of Mud pattern
  50. Summary
  51. Chapter 3: Refactoring Tests
  52. Refactoring tests
  53. The DRY testing pattern
  54. Advantages of the DRY testing pattern
  55. Disadvantages of the DRY testing pattern
  56. Moving code into a setup and teardown
  57. Removing duplication with methods
  58. Removing external test goals
  59. Using a method to fill out the review form
  60. Reviewing the refactored code
  61. The Hermetic test pattern
  62. Advantages of the Hermetic test pattern.
  63. Disadvantages of the Hermetic test patternRemoving test-on-test dependence
  64. Using timestamps as test data
  65. Extracting the remaining common actions to methods
  66. Reviewing the test-on-test dependency refactoring
  67. Creating generic DRY methods
  68. Refactoring with generic methods
  69. The random run order principle
  70. Advantages of the random run order principle
  71. Disadvantages of the random run order principle
  72. Summary
  73. Chapter 4: Data-driven Testing
  74. Data relevance versus data accessibility
  75. Hardcoding input data
  76. Hiding test data from tests
  77. Choosing the test environment
  78. Introducing test fixtures.
  79. Parsing fixture dataUsing fixture data in the tests
  80. Using fixtures to validate products
  81. Testing the remaining products
  82. Using an API as a source of fixture data
  83. Using data stubs
  84. The default values pattern
  85. Advantages of the default values pattern
  86. Disadvantages of the default values pattern
  87. Merging the default values pattern and the faker library
  88. Implementing faker methods
  89. Updating the comment test to use default values
  90. Summary
  91. Chapter 5: Stabilizing the Tests
  92. Engineering the culture of stability
  93. Running fast and failing fast
  94. Running as often as possible.