Why to apply Page Object Model in automation frameworks.
- khyati sehgal
- May 25, 2014
- 2 min read
Today I will share how and why we can apply design pattern concepts while creating a new framework. Let’s try and understand why we need any design patterns in our project. No doubt we can make a framework be it automation or any feature-specific project but if we talk about a big Enterprise edition project then we have to think of factors like
optimal solutions,
performance,
maintainability, etc.
Similarly, we can directly use the play-records plugin of Selenium and start applying further concepts over it.
Then why people are not utilizing it?
Moreover, the inclination is more towards the Selenium web driver whole-some project.
A deep dive.
Let us see what all factors attract a user to use Selenium Webdriver instead of the fact that Selenium IDE can generate automation code in any of your favorite language like Java, etc
The code is rigid.
You can make classes out of the code but not any framework.
You have to certainly perform the record and play option again and again if any test case fails.
This idea will definitely give you a piece of code but not a project on which you can rely upon.
Let’s understand this with a picture, it would be difficult for this guy to find a way. But it would be much easier if something like this might happen to him.
Make sense, yeah…err…no!!
Ok. What I mean is if we can specify directly that what path to take and when, then it might help the reader to understand better, as simple as this.
Design patterns also help us in doing the same stuff for our code, so that we can arrange our code snippets, classes, packages, etc in such a manner that it would help in making code more readable, understandable and manageable.
Advantages of page object pattern:
Makes tests more readable and robust.
Bring down the duplication of code.
Improves the maintainability of tests, remarkably when there is frequent change in the AUT. (Useful in Agile methodology based projects).
Simple and clear tests.
Good support of tests, because everything is stored in one place.
Easy creation of new tests. In fact, tests can be created by a person not knowing the features of automation tools.
The UI changes, the fix need only be applied in one place.
Code re-use: Able to use the same page object in a variety of test cases.
For more details about Page Object Concept in Selenium, scripts check out my next blog.
Comentarios