Selenium WebDriver methods are used to perform operations on Browser and Web Elements. When we get the driver object, the below are the methods that we can perform operation on a driver. In IDE like eclipse, when we add period (. ) you will show all the following methods.

Method Name :- get()

Syntax: get(url)

Example: driver.get(“”);

Purpose: It will load a new web page in the current browser window.

Method Name: getCurrentUrl()

Syntax: getCurrentUrl()

Example: String CurrentUrl = driver.getCurrentUrl();


Purpose: Gets a string representing the current URL that the browser is opened.


Method Name: getTitle()

Syntax: getTitle()

Example: String Title = driver.getTitle();


Purpose: Gets the title of the current web page.

Returns: Facebook – log in or sign up

Method Name: findElements()

Syntax: findElements(By by)

Example: driver.findElements(“email“);

Purpose: Find all elements within the current page using the given mechanism.

Parameters: By – The locating mechanism to use

Returns: A list of all WebElements, or an empty list if nothing matches

Method Name: findElement()

Syntax: WebElement findElement(By by)

Example: driver.findElements(By.xpath(“//”);

Purpose: Find the first WebElement using the given method.

Parameters: By – The locating mechanism

Returns: The first matching element on the current page

Throws: NoSuchElementException – it will return exception if no matching elements are found

Method Name: getPageSource()

Syntax: getPageSource()

Example: String PageSource = driver.getPageSource();


Purpose: Get the source of the currently loaded page. If the page has been modified after loading (for example, by Javascript) there is no guarantee that the returned text is that of the modified page.

Returns: The source of the current page

Method Name: close()

Syntax: void close()

Example: driver.close();

Purpose: Close the current window, if there are multiple windows, it will close the current window which is active and quits the browser if it’s the last window opened currently.

Method Name: quit()

Syntax: void quit()

Example: driver.quit();

Purpose: Quits this driver instance, closing every associated window which is opened.

Method Name: getWindowHandles()

Syntax: Set getWindowHandles()
Example: driver.getWindowHandles();
Purpose: Return a set of window handles which can be used to iterate over all the open windows of this Webdriver instance by passing them to switchTo().WebDriver.Options.window()
Returns: A set of window handles which can be used to iterate over all the open windows.

Method Name: getWindowHandle()

Syntax: String getWindowHandle()

Example: driver.getWindowHandle();

Parameter: Return an opaque handle to this window that uniquely identifies it within this driver instance. This can be used to switch to this window at a later date


WebDriver.TargetLocator switchTo()

The next future commands will be performed to a different frame or window.

Returns: A Target Locator which can be used to switch or select a frame or window

Method Name: navigate().to()

Loads a new web page in the current browser window.

Syntax: driverObject.navigate().to(“url”)




Method Name: navigate().back()

It moves a single item back in the browser history.

Syntax: driverObject.navigate().back()

Example: driver.get(““);



Method Name: navigate().forward()

It moves a single item forward in the browser history.

Syntax: driverObject. navigate().forward()

Example: driver.get(“”);




Method Name: navigate().refresh()

It will refresh the current web page

Syntax: driverObject.navigate().refresh()

Example: driver.get(“”);


Method Name: manage()

Syntax: WebDriver.Options manage()

Purpose: Gets the Option interface

Returns: An option interface

Method Name: sendkeys()

Enters a value into text box

Syntax: driverObject.findelement(“Emelemt Id”).sendkeys(“text”);

Example: driver.findElement(“Email”)).sendKeys(“”);


WebElement text = driver.findElement(“Email”));


Method Name: clear()

It clears the value from an Edit box

Syntax: driverObject.findelement(By.locator(“value”).clear();

Example: WebElement editbox = driver.findElement(“Email”));






Method Name: click()

It clicks an element

Syntax: driverObject.findelement(By.locator(“value”).click;

Example: driver.findElement(“next”)).click();

Method Name: isEnabled()

it checks weather the element is in enabled state or not?

Syntax: boolean variableName = driverObject.findelement(By.locator(“value”).isEnabled();

Example: boolean a = driver.findElement(“next”)).isEnabled();

System.out.println(a); //true

Method Name: isDisplayed()

It checks if the element is displayed or not?

Syntax: boolean variableName = driverObject.findelement(By.locator(“value”).isDisplayed();

Example: boolean a = driver.findElement(“next”)).isDisplayed();

System.out.println(a); //true

Method Name: manage().window().maximize()

Syntax: driver.manage().window().maximize();

Example: driver.get(“”);


Method Name: isSelected()

It checks if the check box or Radio button is selected or not?


boolean variableName = driverObject.findelement(By.locator(“value”).isDisplayed();

Categories: Selenium


What I love doing: Identifying and analyzing business problems with technology, convert Traditional testing methodologies to Automation testing using emerging testing technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *