Currently Browsing

Posts Tagged ‘ Page Object pattern ’

Page Object pattern and Page Factory

As a developer of automated tests for web pages one always has to deal with often changes on a site. This also means constant changes in test cases too. The developers’ main goal is to make as high quality code as possible with the least investment. This is also true for tests changes. Both goals can be reached with using the correct tool. The Page Object pattern hand in hand with Page Factory could provide a healthy code and maintainable tests.
Page Object is one of the most popular patterns which is used for developing automated web test. It maps the pages to objects which contains all the required data and functions that help the developer to test the site. The fields contain all the information what is needed and the methods do all the job to navigate in pages, fill the inputs or click the buttons.
Web driver provides more way to grab the element from the site. All of them are based on search in DOM tree of the webpage based on locators. The locators are strings that describe the position of the required web element. It can be located based on its name, id or src attributes or any custom conditions like CSS or Xpath selector. Let’s take a look for an example. The test case is really simple. Log in to Gmail and check the title of the next site. If the page title contains word Inbox, it’s done. Otherwise something went wrong.