Agenda for this blog: To design frameworks for Selenium by using Java Design Patterns.
Why use Design Patterns in Selenium Framework:
As selenium is an open source tool,so Its does not provide a framework along with it unlike other paid tool.So whoever is using Selenium has to write a framework for it.
Now,If you design your framework by using Java Design Patterns It can have multiple strengths:
1.Well structured code base
2.It will be generic and robust.
3.Framework re-usability and maintainability will be very high
4.Enhancements can be done with very little code changes without disturbing the existing Flows.
5.Debugging of Scripts/framework(if any) will be very easier.
6.Framework can be used with ease by the people who are new to Automation.
What Type of Design Patterns will be useful for Selenium Framework:
First of all it depends on the requirement for the framework as it varies from Company to company and sometimes project to project,but then also there are some generic scenarios where we can use design patterns like Factory Design Pattern,Abstract Design Pattern,Singleton Design Pattern in the framework.
Which Area of a Generic Framework can be developed using Java Design Patterns:
Scenarios:
1.We are having a requirement to use Local WebDriver,Grid, ThreadDriver, HeadLess Driver,EventDriver,RemoteDriver with Sauce Labs Implementation etc.
so there we can use Factory Design Pattern and along with the above feature if you need multiple browsers like FireFox,Chrome,Safari,IE etc etc. then we can use Abstract Factory Design Pattern.
2.If you want to support Data Handling using xls file ,properties file,csv files etc etc there we can use the Factory Design Pattern.
3.We can configure the configuration Class using Singleton Design Pattern.
HOW:
Find the example for different driver implementation using Factory Design Pattern:
We are Creating an Interface ICurrentDriver which is Implemented by all type of Driver Classes such as ThreadDriver,LocalDriver,RemoteDriver because the implementations are different for each of them.
We are Creating an Interface ICurrentDriver which is Implemented by all type of Driver Classes such as ThreadDriver,LocalDriver,RemoteDriver because the implementations are different for each of them.
We can Design another Class Factory which will provide us the Object for the required Driver classes at runtime depending on the need.So we don't need to create and use separate Objects for each of the Driver classes,we will use only Factory class object and can access any of the Driver classes members and fields.
By this way we can use Design Patterns as per the requirement,we can use this concept in case of Handling Data in Selenium Framework.
Visit for More Automation Related Discussion:
https://www.youtube.com/channel/UCKSk4gkmO3LXcW17hFUkmcQ/videos
By this way we can use Design Patterns as per the requirement,we can use this concept in case of Handling Data in Selenium Framework.
Visit for More Automation Related Discussion:
https://www.youtube.com/channel/UCKSk4gkmO3LXcW17hFUkmcQ/videos
do you have a framework on github for parallel cross browser testing using page factory ????
ReplyDelete