Today I will share how and why we can apply design pattern concepts while creating a new framework. Lets try and understand why we need any design pattern 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 inclination is more towards Selenium webdriver whole-some project. 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
- 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 fail.
- This idea will definitely give you a piece of code but not a project on which you can rely upon.
Lets 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 helps 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 tests cases.
In the coming blog I will be discussing how we can apply this Page Object Concept in Selenium scripts.