Selenium WebDriver Methods - Details of Selenium WebDriver Methods

Selenium is the most widely used test automation tool across the globe for testing web based applications. Many of its attractive features make it more popular. It is easy to learn and use. There are several selenium webdriver methods that play important roles in making selenium an user-friendly test automation tool. This article discusses with all those selenium webdriver methods in detail.

Method : get ()

This will load a new web page in the window that is used presently. An HTTP get operation is used here and the method will be blocked until the loading is over.

Syntax: get(url)

Example: driver.get()

Method: getCurrentUrl()

This is used to get a string of current URL opened in the browser.

Syntax: getCurrentUrl()

Example: driver.getCurrentUrl()

Method : getTitle()

Used to get the title of the current web page

Syntax: getTitle()

Example: driver.getTitle()

Method: findElements()

This is used to find all the elements in the page that are used presently with the given mechanism

Syntax: findElements(By by)

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

Method: findElement()

This is used for finding the first web element using the suggested mechanism

Syntax: WebElement findElement (by by)

Example: webdriver.findElement(By.xpath(“//”);

Method: getPageSource()

Used to get the page source of the page loaded currently

Syntax: getPageSource()

Example: driver.getPageSource()

Method: close()

This is used for closing the current window. If multiple windows are open, it will close only the current window.

Syntax: void close()

Example: driver.close()

Method: quit()

This is for quitting the driver instance. Here all the windows opened will be closed.

Syntax: void quit()

Example: driver.quit()

Method: getWindowHandles()

This is used to return a set of window handles that can be used for iterating over all the open windows by passing them to.

Syntax: Set getWindowHandles()

Example: driver.getWindowHandles()

Method: getWindowHandle()

This is used to switched to a window at a later date

Syntax: String getWindowHandle()

Example: driver.getWindowHandle()

Method: navigate()

This is used for accessing the browser’s history and to navigate to a given URL.

Syntax: WebDriver.Navigation navigate()


Method: manage()

This is used for getting option interface

Syntax: WebDriver.Options.manage()

Example: driver.manage()

These are the selenium webdriver methods and more about methods will be taught in selenium tutorials.

Leave a Reply

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