From the course: Learning Selenium

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Page object pattern

Page object pattern - Selenium Tutorial

From the course: Learning Selenium

Start my 1-month free trial

Page object pattern

- [Narrator] One good design pattern for Selenium test is to use the page object pattern. This pattern involves setting up classes for each page in the application to model its behavior. Each page class will be composed of test selectors, and test methods. In the test, a new page object is created, and that object can then call that class's methods directly. The goals of the page object pattern are to have a separation of test and code. It also helps to make tests more maintainable, by being able to go directly to the page object class, and update things there. Let's see how this pattern works in practice. In our test, we have two pages we've interacted with so far. There is the sign up page, and the users page. Each one of those pages will have their own class. I'll first create a page object class for signing up. To do that, I'll go to my text editor, and choose to create a new class called signup_page.rb. Once I'm in my text editor, I can start by creating a new class, and I will…

Contents