Sunday, February 8, 2015

Interaction With HTML Tables


Over the last several months, there has been several opportunities where during a discussion, the subject of HTML tables becomes front and center. The solutions, though, vary greatly from highly nested "for loops" with non descriptive variables to more object oriented, which is the approach being describe here. With small, single purpose methods with good descriptive names, this type of approach allows for cleaner, more readable and maintainable code.

Quick Description And Guide Lines
  • Creates a list of page objects, one for each row in the table
  • Row page object can only perform actions on that single row
  • Use generic non brittle locators for both the table but also for those within the row page object
  • Search base on an unique column or a combination of columns 
  • Return the row page object that matches the search criteria 
  • Performs actions on that page object (row)

In addition, pagination can be easily implemented with a few additional methods.

A working example can be found @ https://github.com/5hawnknight/solid-prototype-table