Page Behavior Method: How rough is too rough?

When we write Page Object Class, we represent page behaviors using methods. But How refine-granulated a method shall be?

Make method as atomic as possible
Suppose that have a page where user can filter the contents by choosing country/city/genre like the following:

Fig.1 – Filter Info

We can have a big method like this (pseudo code):

//This is pseudo code:
void filterInfo(String country, String city, String genre) {
…Then verify displayed info here or outside of page object class

Or we can define atomic methods like this:

//pseudo code
void chooseCountry(String country){

void chooseCity(String city){

void chooseGenre(String genre){

void filterInfo(){

This will give us more flexibility when we define test case logic and make our code more readable:
We can easily simulate these cases:

  • Only choose genre and verify result
  • Only choose city and verify result
  • Filter content by choosing country, city and genre altogether.

This also makes it much easier for us to verify the result of each step, like verifying that all cities of the chosen country is displayed in the ‘City’ drop down, before we go to next step.

I am not saying that we shall give each field a method or several methods to define the way we can manipulate it. Instead, we need to make method refined granulated enough, refined enough to make sense as a user action; so that later on we can call these methods to build up our test cases flexibly.