Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Page objects


In this section of the chapter, we will take a look at how we can apply some best code practices to tests. You will learn how to make maintainable test suites that allow you to update tests in seconds. We will also take a look at how to create your own DSL (Domain-specific language) so that people can see intent. Also, we will create tests using the Page Object pattern.

Let's start trying to put these best practices to work.

Setting up the test

Imagine that you have a number of tests that work on a site that requires you to log in and move to a certain page. Or, imagine that you need to have a test that requires you to be on a certain page. In these two situations, the quickest way to find out which page you are on and then move to the correct one if need be, is to start testing. This is to make sure that we follow one of the major tenants of test automation. In this, you always start from a known place. Let's see this in an example:

  1. Create a new Java class in Eclipse IDE.

  2. Import...