Webdriver Methods In Selenium

In this article, we will learn about webdriver methods in selenium. Selenium WebDriver is a interface and It has many abstract methods like get(String url), quit(), close(), getWindowHandle(), getWindowHandles(), getTitle() etc.

WebDriver Methods in Selenium

1) driver.get (): –

This method opens the specified URL in the current browser window. URL must be in the form of https://www.google.com. If the HTTPS is not included, then it will throw a exception “InvalidArgumentException”. The URL to load and it should be a fully qualified URL

2) driver.getCurrentUrl (): –

The getCurrentURL() method takes nothing as a parameter and returns URL of the web page currently loaded in the browser.

3) driver.getTitle (): –

The getTitle () method takes nothing as a parameter and returns the page title of the currently loaded web page. If the web page has no title, it will return a null String.

4) driver.findElements (): –

Example: driver. FindElements (By. Xpath (“//”);

Find all elements within the current page using this method.

5) driver.findElement (): –

Example: driver. FindElement (By. Xpath (“//”);

Find the WebElement using the given method.

6) driver.getPageSource (): –

Get the source code of the currently loaded page.

7) driver.Close (): –

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.

8) driver.Quit (): –

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

9) driver.getWindowHandle (): –

This is used to get the address of the current browser window where it’s focused on and returns the data type of String.

10) driver.getWindowHandles (): –

This is used to get the address of all the open browsers window and returns the data type of Set<String>.

11) driver.navigate (): –

An abstraction allowing the driver to access the browser’s history and to navigate to a given URL.

A org.openqa.selenium.WebDriver.Navigation that allows the selection of what to do next

12) driver.manage (): –

Gets the Option interface

Other Popular Articles

What is Selenium WebDriver?

Leave a Comment