selenium Tutorial

Selenium is a powerful library of commands in multiple languages (C#, Haskell, Java, JavaScript, Objective-C, Perl, PHP, Python, R, and Ruby) that allow a programmer to automate browser interaction. This is incredibly useful for developers testing applications.

Selenium offers methods to:

  • Find an Element in a webpage
  • Click on an Element
  • Send a String to an Element
  • Navigate to a web page
  • Change to a different tab in the same browser window
  • Take a screenshot of a webpage

Using these methods, a developer can have automatic tests checking:

  • If an Element is in a page, and visible to a user
  • A search or login form
  • Buttons or interactive Elements
  • Check the values or attributes of an Element

Selenium runs in webdrivers, which are similar to a normal web browser but allow Selenium to interact with them. A Selenium test typically opens up a new driver instance of whatever browser the developer is testing in, which is always a clean slate. This way, when running a Selenium test, the developer does not have to worry about previous cookies, or a browser cache affecting the results of their application.

Selenium also works when running a webdriver in headless mode.