Skip to content
Tutorials Center
My learning

Topics

Selenium Tutorial

Learn Selenium step by step: 35 lessons in 10 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Selenium? Learn what Selenium is: browser automation with WebDriver, the IDE and Grid, what it is used for, and how it compares with Playwright and Cypress.
  2. 2 How WebDriver Works See how WebDriver works: your script, a driver program and the browser exchange JSON over HTTP using sessions and element ids defined by a W3C standard.
  3. 3 Setup and Your First Script Install Selenium bindings for Python, Java or JavaScript, let Selenium Manager fetch the driver, then open a page, read its title and quit cleanly.

Finding Elements

  1. 4 Locators: id, name, class and tag Find elements with Selenium's simplest locators: By.ID, NAME, CLASS_NAME and TAG_NAME. Learn find_element versus find_elements and NoSuchElementException.
  2. 5 CSS Selector Locators Use CSS selectors as Selenium locators: ids, classes, attribute matches, combinators and structural pseudo-classes, and why CSS is the default choice.
  3. 6 XPath Locators Learn XPath for Selenium: absolute and relative paths, predicates, text() and contains(), and axes to reach parents and siblings, with runnable examples.
  4. 7 Choosing Stable Locators Pick Selenium locators that survive redesigns: test ids, ARIA attributes, link text, relative locators, and a ranking that tells you which strategy to try first.

Interacting with the Page

  1. 8 Clicking and Typing Learn the everyday Selenium actions: click, send_keys, clear, special Keys, reading text and attributes, and checking is_displayed, is_enabled and is_selected.
  2. 9 Forms, Checkboxes and Dropdowns Automate forms with Selenium: the Select class for dropdowns, checkbox and radio state, reading validation messages, and submitting a form safely.
  3. 10 Mouse and Keyboard: the Actions API Use Selenium ActionChains for hover menus, drag and drop, double and right clicks, key chords and scrolling, and learn why perform() is always required.
  4. 11 Alerts, Frames and Windows Learn how Selenium switches context: handling JavaScript alerts, working inside iframes, and moving between windows and tabs with window handles.
  5. 12 File Uploads, Downloads and Screenshots Handle files in Selenium: upload with send_keys on file inputs, set a download directory and wait for the file, and take element and full-page screenshots.

Waiting and Synchronization

  1. 13 Why Tests Need Waits Learn why a Selenium script races the page it controls, what NoSuchElement, StaleElementReference and ElementNotInteractable errors mean, and why sleep() is a poor fix.
  2. 14 Implicit, Explicit and Fluent Waits Learn Selenium's three kinds of waits: implicit, explicit with WebDriverWait and expected conditions, and fluent waits with polling and ignored exceptions.

Test Structure

  1. 15 The Page Object Model Learn the Page Object Model: one class per page, locators in one place, methods named after user actions, and returning the next page object to keep tests readable.
  2. 16 Selenium with pytest Use pytest with Selenium: a driver fixture with setup and teardown, conftest.py, headless option, parametrized tests and markers, plus a runnable fixture stand-in.
  3. 17 Selenium with JUnit and TestNG Structure Selenium tests in Java with JUnit 5 or TestNG: project layout, setup and teardown annotations, assertions, data-driven tests and suites, with a lifecycle stand-in.
  4. 18 Test Data and Configuration Keep Selenium tests flexible: configuration files, environment URLs, credentials from environment variables, and data-driven tests fed from CSV and JSON files.

Selenium 4 Features

  1. 19 What Is New in Selenium 4 A tour of Selenium 4: W3C WebDriver compliance, relative locators, new tab and window API, element screenshots, DevTools access and BiDi, plus migration tips.
  2. 20 DevTools Protocol and BiDi Use Chrome DevTools Protocol commands and WebDriver BiDi events from Selenium: capture console logs, intercept network calls, emulate devices and geolocation.

Browsers and Scale

  1. 21 Headless Mode and Browser Options Configure Chrome, Firefox and Edge in Selenium: headless mode, window size, proxies, profiles, page load strategy and the W3C capabilities behind options.
  2. 22 Selenium Grid Understand Selenium Grid 4: standalone, hub and node modes, how capabilities choose a node, RemoteWebDriver, Docker images and running tests in parallel.
  3. 23 Cloud Providers and Mobile with Appium Run Selenium tests on vendor clouds and test mobile apps with Appium: remote execution, W3C capabilities, vendor options, costs and when each choice makes sense.

Quality and Reliability

  1. 24 Flaky Tests and Debugging Find and fix flaky Selenium tests: common causes, screenshots and logs on failure, video, why blind retries hide bugs, and how to isolate test state.
  2. 25 Running in CI Run Selenium tests in CI: a GitHub Actions workflow, headless Chrome in containers, pytest-xdist and TestNG parallel runs, and uploading reports as artifacts.
  3. 26 Reporting and Logging Make Selenium runs readable: pytest-html and Allure reports, structured JSON logs, and screenshots, page source and URLs saved automatically when a test fails.
  4. 27 Security, Ethics and Scraping Limits Keep Selenium tests safe and responsible: handle secrets and test accounts, respect robots.txt and terms of service, throttle requests, and know when not to scrape.

Projects

  1. 28 Project: Login Test Suite Build a login test suite step by step: valid and invalid credentials, error messages, lockout, a page object and data-driven cases, with a runnable stand-in app.
  2. 29 Project: Shopping Cart Checkout Automate an end-to-end shopping flow: add items, verify totals, choose shipping from a dropdown, wait for an async checkout and assert the order confirmation.
  3. 30 Project: Form Validation Checks Test form validation with Selenium: required fields, pattern rules, error summaries and accessibility attributes such as aria-invalid and aria-describedby.
  4. 31 Project: Extracting Table Data Build a table extractor: read rows and cells, walk through pagination safely, clean the values and export CSV, with runnable pandas-free stand-ins.
  5. 32 Project: A Small Test Framework Combine a config loader, driver factory, base page, reporting and screenshots on failure into one tidy Selenium test layout, with runnable stand-ins.

Practice and Review

  1. 33 Practice Exercises with Solutions Five hands-on Selenium exercises on locators, waits, page objects, forms and exceptions, each with a hint, a runnable stand-in solution and a discussion.
  2. 34 Selenium Interview Questions Prepare for Selenium interviews with concise answers on WebDriver architecture, locators, waits, exceptions, POM, Grid, flaky tests and Selenium vs Playwright.
  3. 35 Selenium Cheat Sheet A one-page Selenium cheat sheet with Python and Java side by side: locators, element actions, waits, switching, exceptions, browser options and Grid.