Selenium for beginners: what it is and how to start

By SamkhyaAcademy Team · · 6 min read

selenium for beginners

A plain-language guide to Selenium: what it does, a short history, what to learn first, a working first script with explanations, common mistakes, and a first project to put on GitHub.

If you have decided to start in software testing, sooner or later you will hear the word Selenium. It appears in job descriptions, interview questions and course syllabuses, and for good reason: it is one of the most widely used tools for automating web browsers. The good news for beginners is that you do not need to be an expert programmer to start. This guide explains what Selenium is, what to learn first, and how to write your first script.

What is Selenium?

Selenium is a free, open-source set of tools that lets a program control a web browser the way a person would: open a page, click a button, type into a field, and check what appears. Instead of a tester repeating the same 50 steps every time the software changes, a script runs them in minutes. This is called test automation, and it is most useful for regression testing, which means re-checking old features after each change.

A short history that shows why it lasts

According to the Selenium project's own history page, Jason Huggins started Selenium in 2004 at ThoughtWorks in Chicago. He built the first version, called JavaScriptTestRunner, to test an internal time and expenses application, with help from Paul Gross and Jie Tina Wang. After it was open-sourced, others added a server (Selenium Remote Control) and a Firefox record-and-playback tool (Selenium IDE). Separately, Simon Stewart built a tool called WebDriver, and the teams decided to merge the projects. In 2018, WebDriver became a W3C Recommendation, which means the way tools talk to browsers is now an official web standard. Selenium 4 followed in October 2021 with features such as relative locators and a redesigned Grid. Twenty years of history is one reason employers still ask for it.

What to learn before Selenium

  1. Testing basics: test cases, bug reports, regression and smoke testing. Tools do not replace thinking. See our testing interview questions for the core ideas.
  2. HTML and CSS basics: you need to understand elements, ids, classes and attributes, because you will find page elements with them.
  3. One programming language: Python and Java are the most common choices with Selenium. Python is easier for beginners.
  4. Browser developer tools: right-click a page and choose Inspect to see its structure.

A study of 18,752 tech postings by PrepNPlaced from late September to late October 2026 found Python in about 28.2 percent of all postings and SQL in about 21.6 percent, so adding them to your learning is a sound idea even for testing roles.

The main parts of Selenium

  • Selenium WebDriver: the part you will use most. It lets your code control a browser such as Chrome or Firefox.
  • Selenium IDE: a browser extension that records your clicks and replays them. Good for quick experiments, but real projects use WebDriver.
  • Selenium Grid: runs tests on many browsers and machines at the same time. You can learn this later.

Set up in four steps

  1. Install Python from python.org and a code editor such as VS Code.
  2. Install Selenium with pip install selenium.
  3. Make sure you have Chrome installed. Recent versions of Selenium can find or download the matching browser driver for you; if yours does not, install the driver that matches your browser version.
  4. Create a folder for your project and put it under Git. See Git and GitHub for beginners.

Your first script

Practice sites are made for learners and are safe to test. This script opens a demo shop, logs in and checks that the product page appears.

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()
driver.get("https://www.saucedemo.com/")

driver.find_element(By.ID, "user-name").send_keys("standard_user")
driver.find_element(By.ID, "password").send_keys("secret_sauce")
driver.find_element(By.ID, "login-button").click()

WebDriverWait(driver, 10).until(EC.url_contains("inventory"))
assert "inventory" in driver.current_url, "Login did not reach the product page"
print("Login test passed")
driver.quit()

Read it line by line. The first lines import what we need. We open Chrome, go to a page, find elements by their id, type and click, wait until the page changes, then check the result with an assertion. An assertion is the heart of any test: it says what should be true, and fails if it is not.

Finding elements: locators

Selenium needs to know which element to act on. Common locators, from most to least reliable, are id, name, CSS selector and XPath. Prefer ids when they exist, then short CSS selectors. Avoid long XPaths copied from the browser, such as a path with ten levels of divs, because they break whenever the page layout changes.

Waiting properly

Pages take time to load. A beginner's first instinct is to add time.sleep(5) everywhere. That makes tests slow and still unreliable. Use explicit waits instead, which wait only as long as needed for a condition, like an element being visible or clickable, as in the script above. Learning waits early will save you hours of frustration.

Common beginner mistakes

  • Automating before understanding what to test
  • Using fixed sleeps instead of waits
  • Long, fragile XPaths
  • One huge script doing everything instead of small, independent tests
  • No assertions, so the test "passes" even when the app is broken
  • Using real accounts or live production data

What to learn next

Once you can write a few scripts, organise them. Learn a test framework such as pytest, which runs and reports your tests. Learn the Page Object Model, where each page has its own class holding its elements and actions, so a page change needs fixing in one place. Then add reports and run your tests on every code change with a pipeline; our post on CI/CD and testing explains why companies do this.

A first project you can show

Pick a practice shopping site and automate six flows: valid login, invalid login, add to cart, remove from cart, checkout with missing details, and logout. Use pytest, the Page Object Model and clear test names. Put it on GitHub with a README that explains how to run it and includes a screenshot of the test report. That single project proves more than a list of tools on a resume. It also gives you a real story for interviews, which employers increasingly value: a 2026 TeamLease EdTech report says projects, portfolios and internships are becoming key ways to judge freshers.

Selenium or something newer?

Newer tools such as Playwright, from Microsoft, are popular and are worth exploring after you understand the basics. The concepts you learn with Selenium, locators, waits, assertions and page objects, carry over. Many companies still use Selenium, so it remains a safe first choice. For the whole path from zero to your first testing job, read how to become a QA tester with no experience.

Ready for the next step?

Learn Selenium by building and running real test suites. Build real projects in our Testing Automation with AI program. If you would like guidance from people who work in the industry, join our free career guidance workshop or request a free career discovery session. We will look at your background and help you plan what to learn and build next.

Need career guidance from industry experts?

Join our free workshop or request a free career discovery session.

Keep reading