Skip to main content

Method Overloading: Method overloading is a feature of Java in which a class has more than one method of the same name and their parameters are different.

Overloaded method in Selenium are:

  1. frame(string), frame(int), frame(WebElement)
  2. findElement("<All type of locator e.g. id , xpath , cssClass>").
  3. wait(), wait(timeout), wait(timout,nanos)

Example: Select and Deselect List

public class MyList
{ 
    Select list; 

    public Listbox(Select list) 
    {
        this.list = list; 
    } 
    
    public void select(int i) 
    { 
        this.list.selectByIndex(i); 
    } 

    public void select(String text) 
    { 
        this.list.selectByVisibleText(text); 
    }

   // Same way you can do it for deselect and other methods
}

About

Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.