1OOP focuses on the objects that are
2required to be manipulated instead of logic.
3- It makes development and maintenance easier
4- It provides data hiding
5- It provides ability to simulate real-world
6- less memory and organized
7- reusable
8
9OOP language follow 4 principles:
101-ENCAPSULATION: We can hide direct access
11to data by using private key and we can access
12private data by using getter and
13setter method. in my framework I have POJO
14class which I use it when we need to represent
15some data as Java object. So to that we need to
16create a Java class to represent it's data.
17So in POJO class I use encapsulation and
18getter setter method to access them.
19
202-ABSTRACTION: It is a process of hiding
21implementation details and showing only
22functionality to the user. Abstraction lets
23you focus on what the object does instead of how it does it.
24In my framework I have created my
25PageBase class as super
26class of the all page classes.
27I have collected all common elements
28and functions into PageBase class and
29all other page classes extent PageBase class.
30By doing so, I don't have to locate very
31common WebElements and it provides
32reusability in my framework.
33
343-INHERITANCE: It is used to define the
35relationship between two classes. When a
36child class acquires all properties and
37behaviors of parent class known as inheritance.
38Child class can reuse all the codes written
39in parent class. It provides the code
40reusability. in my framework I have
41a TestBase class which I store
42all my reusable code and methods.
43My test execution classes and
44elements classes will extend the
45TestBase in order to reuse the code.
46
474-: POLYMORPHISM: It is an ability of object
48to behave in multiple form. The most common use
49of polymorphism is Java, when a parent class reference
50type of variable is used to refer to a child
51class object.
52I use polymorphis almost everywhere
53It is an ability of object to behave in multiple
54form. The most common use of polymorphism is Java, when a
55parent class reference type of variable
56is used to refer to a child class object.
57E.g.: WebDriver driver = new ChromeDriver();
58JavaScriptExecuter js = (JavaScriptExecuter)Driver.getDriver;
59TakeScreenshot screen = (TakeScreenshot)Driver.getDriver;
60WebDriver driver = new ChromeDriver();
61
62
63
1class Person {
2 void walk() {
3 System.out.println(“Can Run….”);
4 }
5}
6class Employee extends Person {
7 void walk() {
8 System.out.println(“Running Fast…”);
9 }
10 public static void main(String arg[]) {
11 Person p = new Employee(); //upcasting
12 p.walk();
13 }
14}
1OOP focuses on the objects that are
2required to be manipulated instead of logic.
3- It makes development and maintenance easier
4- It provides data hiding
5- It provides ability to simulate real-world
6- less memory and organized
7- reusable
8
9OOP language follow 4 principles:
101-ENCAPSULATION: We can hide direct access
11to data by using private key and we can access
12private data by using getter and
13setter method. in my framework I have POJO
14class which I use it when we need to represent
15some data as Java object. So to that we need to
16create a Java class to represent it's data.
17So in POJO class I use encapsulation and
18getter setter method to access them.
19
202-ABSTRACTION: It is a process of hiding
21implementation details and showing only
22functionality to the user. Abstraction lets
23you focus on what the object does instead of how it does it.
24In my framework I have created my
25PageBase class as super
26class of the all page classes.
27I have collected all common elements
28and functions into PageBase class and
29all other page classes extent PageBase class.
30By doing so, I don't have to locate very
31common WebElements and it provides
32reusability in my framework.
33
343-INHERITANCE: It is used to define the
35relationship between two classes. When a
36child class acquires all properties and
37behaviors of parent class known as inheritance.
38Child class can reuse all the codes written
39in parent class. It provides the code
40reusability. in my framework I have
41a TestBase class which I store
42all my reusable code and methods.
43My test execution classes and
44elements classes will extend the
45TestBase in order to reuse the code.
46
474-: POLYMORPHISM: It is an ability of object
48to behave in multiple form. The most common use
49of polymorphism is Java, when a parent class reference
50type of variable is used to refer to a child
51class object.
52I use polymorphis almost everywhere
53It is an ability of object to behave in multiple
54form. The most common use of polymorphism is Java, when a
55parent class reference type of variable
56is used to refer to a child class object.
57E.g.: WebDriver driver = new ChromeDriver();
58JavaScriptExecuter js = (JavaScriptExecuter)Driver.getDriver;
59TakeScreenshot screen = (TakeScreenshot)Driver.getDriver;
60WebDriver driver = new ChromeDriver();
61
1public class YourClass {
2 String example;
3 int test;
4
5 // Constructor
6 public YourClass(String example, int test) {
7 this.example = example;
8 this.test = test;
9 }
10
11 // Method
12 public void someMethod() {
13 System.out.println(example);
14 }
15}
16
17// Usage:
18// Construct
19YourClass exampleObject = new YourClass("Hello World!", 5);
20// Execute Method:
21exampleObject.someMethod();