Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Selenium Design Patterns and Best Practices
  • Table Of Contents Toc
  • Feedback & Rating feedback
Selenium Design Patterns and Best Practices

Selenium Design Patterns and Best Practices

By : Kovalenko
3.9 (11)
close
close
Selenium Design Patterns and Best Practices

Selenium Design Patterns and Best Practices

3.9 (11)
By: Kovalenko

Overview of this book

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.
Table of Contents (11 chapters)
close
close
10
Index

The Record and Playback pattern

Let's start with the very first test development pattern: the Record and Playback pattern. This is the starting point with majority of Selenium and other automated user interface testing tools. The idea behind this approach of test development is to allow the user to record their normal testing activities and play them back through the testing tool at a later date.

Advantages of the Record and Playback pattern

Having a tool record our interaction with the application has several advantages; chief among them is the speed at which we can grow our test suite. Let's take a look at individual advantages:

  • Fast test growth: This is the biggest selling point in most commercial tools available. A user is able to record new individual tests as fast as he or she can click on links. A large test suite can be created in hours instead of weeks.
  • No previous experience: It does not require any experience with programming language, just click on the record button and click around. Let the tool write the actual test code.
  • Element lookup: It is incredibly easy and useful, and there is no need to look at the page source to find the button by hand. Just click on record, click on the desired button, and the element location is recorded in the test for you.

Disadvantages of the Record and Playback pattern

The commercial testing tools will give you a very large list of great features, which may sound too good to be true. In actuality, these features probably are too good to be true; every recording tool has these and many more disadvantages:

  • Bad locators: These are a common problem with recording tools. Often a tool will record the absolute path to an element. If the desired button shifts left or right on the page, the playback of the test might fail even though the application works perfectly fine.
  • Inflexible tests: These are the only output from recording tools. Since the playback is identical to the recording process, the final result is an identical copy of the recording. However, what if a test needs to register a new unique user for each run? To accommodate this task, it often takes more time than to write the test by hand in a programming language.
  • Hardcoded test data: It is a big problem if your tests need to be flexible and use different data depending on the environment. We will discuss test data in Chapter 4, Data-driven Testing.
  • Poorly written tests: Just like many WYSWYG tools available for writing code, the task of creating something is simple. However, the maintenance becomes incredibly difficult, as variable names and method names might be poorly named or strangely nested within each other.

    Note

    What You See (is) What You Get (WYSWYG) is a name for tools that allow users to quickly mock up an application interface. Using the final product of a WYSWYG tool in production is generally considered a bad idea and should be avoided.

  • Duplicate code: It is one of the examples of poorly written tests. Most recording tools are not intelligent enough to detect duplicate steps and will not reuse existing code. See the The DRY testing pattern section in Chapter 3, Refactoring Tests.

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY