Skip to main content

Selenium

Pronunciation
suh-LEE-nee-um
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/selenium

In short

Selenium is an open-source suite of tools for automating web browsers, used mainly for end-to-end testing, with its WebDriver API available in many languages.

What is Selenium?

Selenium began in 2004 at ThoughtWorks, where Jason Huggins wrote a tool to automate repetitive testing of a web app. Its core today is WebDriver, an API that controls real browsers, including Chrome, Firefox, Safari and Edge, through each browser's own driver. The WebDriver protocol became a W3C standard in 2018, so browser makers implement it directly.

Tests can be written in Java, Python, C#, JavaScript, Ruby and other languages, which makes Selenium popular in teams whose main language isn't JavaScript. A test opens a page, finds elements by ID, CSS selector or XPath, clicks, types and asserts what appears. Selenium Grid runs tests in parallel across many machines and browser versions, and Selenium IDE records and replays browser actions.

Its long history means huge numbers of existing test suites, integrations with every CI system and cloud testing services, and plenty of documentation. Many commercial testing platforms are built on Selenium and WebDriver underneath.

A common misconception is that Selenium tests are inherently flaky. Flakiness usually comes from tests that don't wait properly for the page, using fixed sleeps instead of explicit waits for elements to appear. Newer tools such as Playwright and Cypress wait automatically, which is a big reason many new projects choose them, but well-written Selenium suites can be just as reliable.

Key takeaways

  • Selenium automates real web browsers, mainly for end-to-end tests.
  • It started in 2004; WebDriver became a W3C standard in 2018.
  • Tests can be written in Java, Python, C#, JavaScript, Ruby and more.
  • Selenium Grid runs tests in parallel across browsers and machines.
  • Explicit waits, not fixed sleeps, keep Selenium tests reliable.

Example

A login test with Selenium WebDriver (Python)python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
try:
    driver.get("https://staging.example.com/login")
    driver.find_element(By.ID, "email").send_keys("ada@example.com")
    driver.find_element(By.ID, "password").send_keys("correct horse")
    driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click()

    # Explicit wait instead of time.sleep(): wait until the heading appears
    heading = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.TAG_NAME, "h1")))
    assert "Dashboard" in heading.text
finally:
    driver.quit()

Readers ask

What is the difference between Selenium and Playwright?

Selenium is older, supports many languages and uses the standard WebDriver protocol. Playwright is newer, controls browsers through their debugging protocols, waits automatically and includes tracing and parallel runs out of the box. Both test real browsers.

What is Selenium WebDriver?

The main part of Selenium: an API and protocol for controlling a browser programmatically, opening pages, finding elements and simulating user actions such as clicks and typing.

What is Selenium Grid?

A way to run Selenium tests on many machines and browsers in parallel, by sending commands from the tests to a hub that distributes them to browser nodes.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings