Hi everyone,

It’s me Thanh, but I’m not the author for the post today as usual. Instead, I would like to introduce you a guest post from Brian Van Stone. Brian Van Stone has been working with QualiTest for nearly 5 years, enjoying various roles in test automation before assuming his current role as Solutions Architect. In this post today, Brian would like to share an overview of his favorite automation framework in Selenium and I hope you see useful.

Alright, here we go…

Choosing the right test automation framework is key to the success of your software testing project. When it comes to things like ROI and how much time and labor we can save ourselves through test automation, it’s easy to say that test automation is going to save the day. However, that’s not always true.

A large challenge with creating any test automation suite is ensuring simultaneous scalability, maintainability, and reliability. To ensure that you can meet these criteria, you must select the right framework for your needs.

One of my favorite framework approaches is a Page Object Model framework. Successful page object framework simplifies test case creation and test development time by grouping lower level actions into a single, high level action. Used properly, it can be applied to multiple scenarios and can easily be extended to include additional functionality.

Understanding Page Object Frameworks

So what does this mean?

Page object is designed to be broken down into sections, where each component of the framework corresponds to a portion of the website under test. The purpose is to make it easier to write test cases by separating parts of the page (break down the page into different parts, like a bunch of links, and different menus) and interactions with different parts of the page, like clicking a button, or navigating to a different page.

The purpose is to enable test developers to design tests in a high-level logical manner and to focus on building the tests instead of devoting energy to functions for minor details on the page.

Why is Reusability important?

Abstracting the pages and making the code reusable will make the framework exceedingly easier to maintain. When there are changes to the page, you only have to modify the components related to that page, instead of a thousand different places.

It’s also easier to make understandable test cases. In our experience, it also makes it easier to add new test cases, because all of the components of the page are already there. The only code that you need to write for interacting and verifying the page is already there, so you only have to carry out different actions. With most test automation services, the idea is to do all the upfront work with the framework, and then writing test cases will be easier.

What are the challenges?

There are some key challenges to the Page Object Model approach, but most involve dealing with edge cases or uncommon scenarios. However, some of the challenges include the following:

1) Maintaining locators, which is how you find things on the page. In a page object methodology, this is done by hard-coding to the file. You want to be able to not hard code things like xpaths in order to make them reusable.

In Selenium, locators are the way to specify which component on the page you want to interact with, most commonly xpaths. Because xpaths are the core of web design, when you change the layout of the page, the xpaths will change. However, with a stable page layout, maintenance can be minimized over multiple pages.

2) Because page object design is object oriented, the process of framework design should include an immense amount of consideration about how you organize the objects that need to be tested, the frequency of the testing, and how these objects interact with each other during testing.

Similar to a template in WordPress, you can have the same template, but different uses for that template. You need to have utilitarian code that deals with pages in general. This means handling cross browser interactions and javascript consistently, and providing common methods to perform actions that aren’t directly in selenium, like actions directly related to your application, and reusable common utilities.

How to overcome those challenges

As with anything that is object-oriented, success is about finding and implementing common functionality, as well as understanding where the implementation of that functionality could vary. The output is the same, but how you achieve that output varies with the code. So you have to put together a class hierarchy, which is typically done using UML diagrams.

You should also perform a breakdown of the application under test. This will allow you to enumerate various pages to interact with, and common things to do with those pages, like entering form data or clicking buttons.

Basically, there should be a robust and clearly developed plan before development to maintain framework stability and ease of long term maintenance of the framework and the test

Final thoughts

Don’t be fooled into creating one-off test automation scripts that address only specific application requirements! Sometimes, organizations mistakenly conclude that they need to reuse existing manual test suites that were not designed with modularity and reusability, or that their applications are too unique or complex for generic design approaches to work. The keys to unlocking success with any Selenium implementation are good design, process and reusability and you can achieve that with Page Object Model Framework.

Author Bio

Brian Van Stone – Solutions Architect

Brian Van Stone has been working with QualiTest for nearly 5 years, enjoying various roles in test automation before assuming his current role as Solutions Architect. Prior to his time with QualiTest, he worked as a Systems Engineer in the utilities industry with a focus on web and web service infrastructure and load balancing. You can have more information on https://twitter.com/QualiTest

Like What You’ve Read?