Test Automation Considerations





Page Object Model

  • locators and actions upon them in same class
  • anything can be a page object
  • HomePage
    • import footer
    • import header
    • import CTA
    • import admin menu
  • Actions with multiple steps supported
  • Some say to make all methods static, but not sure good idea with elements with 'hashed' attributes/names
  • Inherently creates intellisense dot-syntax api
  • lends itself to injecting abstraction layers


Object Library

The correct approach is to

  • have the locators in each page object class as By variables or

  • use page factory which declares the web elements and their locators together

In my opinion, using object repositories in Selenium projects is a bad practice.

The object repository concept comes from record-and-playback tools such as QTP.

The object repository is a tree-like structure that is created while recording a test.

It has attributes for each element of the page used in the test.

Selenium does not have any record-and-play feature for test automation (Selenium IDE is not an automation tool).

Using object repositories in Selenium projects (as property or csv or xml files) has many disadvantages such as

  1. since each locator is a line in a text file, it is impossible to open the declaration of the locator in the IDE (using F3 or Open Declaration)

  2. page object classes with no locator variables break the class encapsulation principle (methods of a class should execute on variables of a class)

  3. object repositories do not scale well for big pages; since big pages are bad and should be broken down in small pages, should we not have object repositories for each page widget?

  4. object repositories do not work with page factory

Read more about the disadvantages on this medium.com article: https://medium.com/@alexsiminiuc3/dont-use-object-repositories-with-selenium-webdriver-ad14096528e5


ObjectL => ClusterF

  • https://medium.com/@alexsiminiuc3/dont-use-object-repositories-with-selenium-webdriver-ad14096528e5
  • Remenant Barbarism from Capture/Playback
  • Telerik Test Studio failed miserably with a client - obscene situation ensued until I fought for ditching the UI joke & invest in code-based solution ( same Telerik framework ).
  • BUT...
    • there are no absolutes..
    • OL's can be leveraged to great effect in certain scenarios
      • Data Driven Testing
        • massive database of permutations ( API Testing ) would justify creating 'machinery' or a 'test engine' where POM is over-engineered design pattern for acute UI actions.
    • After critical mass reached,
      • the larger the UI, larger the disaster
  • First automation experience predates the concept of 'elements'
    • WindowsNT fat client
    • Point Of Sale with sprawling UI
      • multiple flavors for each client
    • Object Repo was MOUSE COORDS
    • This worked because the UI was RARELY changed
      • once UI decided, neither client nor development firm want changes
        • Client - costs for training, financial errors due to user confusion, brand damage for wait times during acclimation, new manuals, etc
        • Developer - forking UI for each client increases cost for everyone - along with greater risk.


What are the disadvantages of an object repository?

An ecommerce site has more than 50 pages, each with hundreds of elements.

We will have then an object repository for each page.

While working with code, there are many times when we need to either read or change the value of a locator.

Usually, this is done in the IDE (Eclipse, Intellij) by pressing the F3 key or selecting Open Declaration for the locator variable:

Image for post

Image for post

This does not work with object repositories since a locator is just a line in a text file.

To read or change the locator value, you have to

  • find the object repository for the page
  • open it
  • search for the element name in the file

That’s a lot of work for just reading a locator value.



Page Factory

  • Not a fan
  • Assumes only one locator needed
    • fails miserably with CKEditor's.. "nameless iframe with html/body tag"
  • Hunts down ALL elements on page instantiation
    • Not sure how this works with AJAX call back for 'mutli-value' fields with 'add another' button