In this chapter, we learned about design patterns that we can use with Selenium WebDriver. We learned techniques that allow us to build test projects that are easy to maintain and readable by all users.
Specifically, we covered:
Page Objects: This is a technique where we split the test logic into separate classes. This allows us to create a Java class for each of the pages that we use on the page.
Page Factory: This allows us to decorate our
WebElement
variables in our Page objects so that we remove a lot of the look up code. We learned that the elements get initialized when we callPageFactory.initElements();
in our tests or anything else that might use this code.LoadableComponent
: In this section, we had a look at the base page for Page Objects that comes with the Selenium project. TheLoadableComponent
in a base class that allows us to remove quite a bit of code and moves the boilerplate toLoadableComponent
.
Now that we've learned about design patterns, we're ready to look at...