Selenium Webdriver Methods
Selenium Webdriver Methods will discuss about the API provided by the Selenium Webdriver. We have so many webdriver methods to automate the web application. Selenium provided huge number of methods to interact with the browser to automate the applications. Each method will have its own purpose to use.
Below are the few important methods which we will use very frequently:
Method | Description |
---|---|
close() | It will close the current browser where the driver focus is. |
findElement() | It will identify the single web element on the web page. |
findElements() | It will identify the list of web elements which is having same locator. |
get() | It will be used to navigate to the particular website. It accepts the url as an argument. |
getCurrentUrl() | It will give the url of the currently focused web page in the form of string. |
getPageSource() | It will return the entire page source(i.e. Html code) of the currently focused web page in the form of string. |
getTitle() | It will return the title of the currently focused web page in the form of string. |
getWindowHandle() | It will be used the get the current window information. By using this we can switch between the windows. Return type of this method is WebDriver. |
getWindowHandles() | It will hold all the windows information which are opened by the web driver. By using these information we can switch between the opened windows. |
navigate() | It will be used to navigate to the previous and next web pages. |
quit() | It will be used to close all the web pages which are opened by the webdriver. |
switchTo() | This will be very helpful to switch between the windows, frames and alters in the application. |
clear() | This method is used to clear the content of the textbox. |
sendKeys() | This method is used to enter the data into the textbox. |
click() | This method is used to click on the buttons or links on the web page. |
getAttribute() | This method will be used to get the attribute values of a particular locator. |
submit() | This method will be used to submit the form on a webpage. |
selectByVisibleText() | This method will be used to select a value from the drop down using the text of the options in the drop down. |
selectByIndex() | This method will be used to select a value from the drop down using the index value. |
selectByValue() | This method will be used to select a value from the drop down using the value attribute. |
These are the methods which we will use very frequently while automating the application using selenium webdriver. Will discuss all these things in the coming blogs.
Please watch the YouTube video for this blog for better understanding.