One accepts reference to a file and another accepts reference to a database. So you introduce to methods resetTestData. Your framework supports test data to be stored in either a file or in database. For example you provide a method that resets test data. This can be used when you introduce new public code and try to maintain backward compatibility for old tests which use your framework or when you just introduce some flexibility to your framework. ![]() You might want your test framework methods to support different types of incoming data so that you introduce methods having the same name but accepting different types of parameters. Polymorphism is more often used in test framework development rather then in tests themselves. This is also widely used in Page Object design pattern because the pieces of a real UI often extend other pieces of that UI and hence it makes sense to transfer that model to your Page Object model using inheritance mechanism. This can be used (but not limited by) to extend the existing test class with additional tests, or to store the common utility code in parent class. This also makes sense to segregate private and public parts for a kind of utility code in your test classes and even if you are the only person working with the tests because you might forget what logic you initially put to your code. Hence you mark that code as private so that the testers which use your framework will not be able to call that piece of code and introduce inconsistency. When you write some code (especially when you develop test frameworks) you might have the code that is to be called in some prescribed cases or in some prescribed order and calling that code in different cases might break the framework state. You are to use this principle in your tests to segregate public methods and fields from private ones. However below is what my experience shows. Whenever we use a method that was already implemented/written in another class by changing its parameters this is the example of method overriding.I do not believe there could be some special advice for testers on how to use the OOP principles since as soon as you open your IDE and start writing code you stops being a tester and starts being a developer in test. If the subclass or child class has the same method as declared in the parent class, it is known as method overriding in Java. In Implicit wait when we use different time stamps such as SECONDS, MINUTES, HOURS, etc is one of the possible examples of method overloading. ![]() If a class has multiple methods having the same name but different in parameters, it is known as Method Overloading. In Java polymorphism can be achieved in two ways: METHOD OVERLOADING Polymorphism allows us to perform a single action in different ways. All the classes which we write in our automation framework are an example of Encapsulation.įor e.g In Page object model classes, in which we declare the WebElement locator using and initialization of this data members will be done using Constructor to utilize those in test methods. In this case, extending one class into another class is an example of implementing Inheritance.Įncapsulation is a mechanism of wrapping data (variables) and code together as a single unit. When We create a Base Class in our automation Framework to initialize WebDriver interface, waits, loggers, reports, etc., and when we extend this Base Class in other classes such as Tests and Utility Class. The process by which one class acquires the properties (instance variables) and functionalities of another class are called inheritance. In our Automation Framework whenever we Use the Page object Model, we write all the locators in the page class and use this locator in our test it means we are hiding our implementation from the user this is a simple example of using abstraction in the framework. It also helps to reduce programming complexity and effort. ABSTRACTIONĪs we are aware, Abstraction is a process of hiding the implementation details from the user and showing only relevant details to them. Here WebDriver is an Interface as mentioned earlier and Chromedriver is a class. It means we are creating a reference variable (driver) of the interface (WebDriver) and creating an Object. ![]() ![]() So based on this statement, WebDriver driver = new Chromedriver() we are initializing chrome browser using Selenium WebDriver. In this case, WebDriver itself is an Interface. To understand this the very basic statement we write in Selenium WebDriver driver = new Chromedriver() An interface also contains methods and variables just like the class but the methods declared in the interface are by default abstract. Java Object-Oriented Concepts in Selenium Automation Framework INTERFACEĪn interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |