Creating generic DRY methods

At this point, our test is no longer recognizable compared to what it was at the beginning of the chapter. Before we wrap it up, let's talk about the generic action used all through our tests. Throughout the test code, we use some common methods to perform actions such as clicking or typing text into a text field. These chained methods look something like this:

Creating generic DRY methods

What if we refactor these methods a little further and create some generic private methods that can be used in a much simpler way? Let's start with the most common method used, @selenium.find_element, and create a generic find_element method:

Our find_element method ...

Get Selenium Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.