Home >>Selenium Tutorial >Selenium WebDriver Commands

Selenium WebDriver Commands

Selenium WebDriver Commands

As we discussed in the IDE section earlier, Selenium commands are the set of commands used to run our selenium tests.

We have a completely different set of commands in Selenium WebDriver for running various operations. Since we use Java with Selenium WebDriver, commands are simply Java-written methods.

We demand that you go through the Java OOPs (Object-Oriented Programming) concepts in the java programming language before going into the specifics of commands given by Selenium WebDriver. You can also refer to the definition portion of our Java OOPs given in the Java Tutorial.

We have produced our first test script in Selenium WebDriver so far, successfully. Thus one way to display WebDriver 's methods is to open the Eclipse IDE loaded with Selenium Webdriver jar archives, build a WebDriver driver object and click the dot key. It'll give you all of WebDriver 's potential methods.

Method Name

In order to use any function of any type, we need to create a type property, and then all the public methods exist for the category.


A parameter is an argument that is passed on to a process to conduct a particular operation.

Return type

Methods will return a value or returning nothing (void). If the void is mentioned after the method, it means, the method is returning no value. If it returns a value, then the value form for e.g. getTitle): (string must be shown.

Now we are going to discuss the various commands WebDriver offers. Selenium WebDriver commands can be generally classified in the following categories.

  1. Browser Commands
  2. Navigation Commands
  3. WebElement Commands

1.Fetching a web page

There are two methods to fetch a web page:

  • Using Get method
  • Using Navigate method

2. Locating forms and sending user inputs

driver.findElement(By.id("lst-ib")).sendKeys("phptpoint tutorials");  

3. Clearing User inputs

The clear() method is used to clear the user inputs from the text box.


4. Fetching data over any web element

Often for some statements and testing we need to retrieve the text written over a web element. We use the method getText() to retrieve data written over some web element.


5. Performing Click event


6. Navigating backward in browser history


7. Navigating forward in browser history


8. Refresh/ Reload a web page


9. Closing Browser


10. Closing Browser and other all other windows associated with the driver


11. Moving between Windows


13. Moving between Frames


14. Drag and Drop

Drag and Drop operation is performed using the Action class.

WebElement element = driver.findElement(By.name("source"));  
WebElement target = driver.findElement(By.name("target"));  
(new Actions(driver)).dragAndDrop(element, target).perform();