Book Image

Selenium Essentials

By : Prashanth Sams
Book Image

Selenium Essentials

By: Prashanth Sams

Overview of this book

Table of Contents (12 chapters)

Basic WebDriver functions


Consider a test use case with the user opening a browser, searching for a term, asserting the actual value with the expected value, and then finally exiting the browser. This simple use case can certainly be achieved using the basic Selenium WebDriver functions. The elementary functions, such as click(), close(), submit(), and sendKeys(), are the fundamental keys to start with any test automation tasks. Let's discuss the basic WebDriver functions in more detail:

  • close(): This function exits or closes the current active browser window. The following is the syntax for this function:

    driver.close();
  • quit(): This function halts the running driver and closes every browser window by ending the active session. The following is the syntax for this function:

    driver.quit();
  • getTitle(): This function fetches the current page title. The following is the syntax for this function:

    driver.getTitle();
  • getCurrentUrl(): This function gets the current web page URL. The following is the syntax...