We have already discussed OOP in our first lecture of this course. Today we will talk about below 4 pillars of OOP Abstraction Encapsulation Inheritance Polymorphism Abstraction Abstraction is a concept aiming to hide relevant data about an object and expose a high-level mechanism for using it, which in turn increase efficiency and reduce complexity. For example, In Test Automation we use IWebDriver object for communication with the browser, we can open the URL and close the browser using available methods. Here we are not aware of how the communication with the browser is actually done. In Simple terms, IWebDriver object hides all the internal details and gives us methods for using it Below sample code IWebDriver driver = new ChromeDriver (); driver . Navigate() . GoToUrl( "https://www.google.com/" ); driver . Close(); Its ok, if you do not understand the code for now. We will talk about IWebdDriver i...
Methods are used in our code to implement common and specific behavior. We add a method to our class that defines the operations of the class. Today we will talk about some concepts around the methods, let's start Method Overloading Here we have multiple methods with the same name and purpose however with a different signature. They also have the same return type. Requirement Suppose in your automation project you want to write a common method that writes text to say textbox, text area etc. You have 2 choices here, you can clear the existing text and write a new one or you can append the new text to existing text if any. We can use method overloading here, we will add 2 SendKeys methods, one takes a single parameter(the text which one wants to write) and other method takes 2 parameters (text and the clearFlag, which can be used to clear/not clear the input before entering the text) Check below code We could have...
One can manage a group of items/objects using arrays or collections, we have already talked about arrays in the previous lecture, today we will talk about collections Collections provide a more flexible way to work with a group of objects. Yes flexible, collections can grow and shrink dynamically . One of the greatest advantage over Arrays. There are many collections provided by .Net framework, we will look at the most used collection classes Generic List Strongly typed list of elements that can be accessed by using positional index number. Declaration List < string > EmpNameList ; Declared EmpNameList which will hold elements of type string Initialization EmpNameList = new List < string >(); Operations //Add Element EmpNameList . Add ( "Employee1" ); //Re...
Comments
Post a Comment