Methods In Java - Tutorials For Selenium WebDriver

What Is Method?
In Selenium webdriver essay out suite for software spider web application, You take away to perform merely about actions multiple fourth dimension or inward multiple essay out cases similar Login inward to Account of software spider web application, Place Order or whatsoever other activity on software application. If you lot volition write this form of (same repeated) actions In all the essay out cases in addition to therefore It volition becomes overhead for you lot in addition to volition Increase size of your code. Instead of that, If you lot exercise methods for this form of operations in addition to and therefore telephone telephone that method whenever required in addition to therefore It volition travel rattling slow to hold your essay out cases of software spider web application.

Method Is grouping of statements which is created to perform merely about actions or functioning when your coffee code telephone telephone it from principal method. Code written Inside methods tin non travel executed yesteryear It self. To execute that method code block, You take away to telephone telephone that method within principal method block. Let me rank you lot unproblematic instance of how to exercise a method in addition to how to telephone telephone It from principal method block.

Simple Method Example :
public shape Methodexample {   world static void main(String[] args) {   Test1(); //Test1() method called within principal method.     }    world static void Test1(){ //Simple Method - Called from principal method.   System.out.println("Test1 Method Executed.");  }    world static void Test2(){ //Simple Method - Not called from principal method.   System.out.println("Test2 Method Executed.");  }  }

If you lot volition run inward a higher house instance in addition to therefore console output volition looks similar bellow.
Test1 Method Executed.
As per the console output, We tin say that Test1() method is executed but Test2() method is non executed because It Is non called from principal method.

Methods volition convey bellow given dissimilar components.

1. Visibility Of Method : You tin gear upward your method's visibility yesteryear providing access modifier keywords similar public, private, protected at kickoff of method. VIEW DETAILED EXAMPLE.
Example :
public static void Testing_Nomod(){ //public method   //Block of code }

2. Return Type Of Method : Any method tin convey provide types similar int, String, double etc.. based on returning value's information type. void agency method is non returning whatsoever value.
VIEW EXAMPLE OF RETURN TYPE
Example :
public int Return_Type(){ //This method has int provide type.   int i=10;   return i;  }


3. Static or non static method : Method tin travel static or non static. If you lot wants to proceed your method every bit static in addition to therefore you lot take away to exercise static keyword amongst method. If you lot wants to exercise non static method in addition to therefore exercise non write static keyword amongst method. VIEW FULL DESCRIPTION ON STATIC AND NON STATIC.
Example :
public void My_Method1(){ //Non static Method   //Block of code  }   world static void My_Method2(){ //Static Method   //Block of code  }

4. Method Name : You tin rank whatsoever advert to your method. Always exercise method advert relative to its functional work.
Example :
public static void Login(String user, String Pass){ //Login is the method name.   //Block of code  }

5. Input Parameters To Method : We tin cash inward one's chips Input parameters to whatsoever method. Need to write parameter amongst its information type.
VIEW EXAMPLE OF INPUT PARAMETERS
Example :
public static void Student_Details(int Rollno, String Name){ //Rollno in addition to Name are input parameters preceded yesteryear their information types   //Block of code  }

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM

http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post