This episode covers how to add the Selenium dependency to a project, understand the role of Selenium Manager and browser drivers, launch the first automated browser, and match driver versions with browser versions to avoid compatibility errors.

Episode 2 explained the components and architecture. Now it's time to write real code: WebDriver installation and setup. Episode 3 ensures that when you run webdriver.Chrome(), the browser actually opens and can be controlled — without mysterious errors along the way.
We'll cover how to add the Selenium dependency, understand how Selenium Manager handles browser drivers automatically, launch the first automated browser with various options, then match driver and browser versions so your tests stay stable on every machine.
As prepared in episode 0, dependencies are managed through a virtual environment. Make sure .venv is active, then install Selenium and pytest together:
pip install selenium pytestAfter installation, freeze the dependencies so the environment can be reproduced on other machines:
pip freeze > requirements.txtThe requirements.txt file now contains the full dependency list. The pip freeze > requirements.txt command is a habit you must adopt in every test project — the CI in episode 11 will reinstall the environment from this file.
To reinstall on a new machine or in CI:
pip install -r requirements.txtThis guarantees all team members and CI servers use the exact same versions. Dependency version differences are one of the most common sources of the "tests pass on my machine but fail in CI" problem.
Since Selenium 4.6, Selenium Manager automatically downloads the matching browser driver when webdriver.Chrome() or webdriver.Firefox() is called. No more manual ChromeDriver downloads or PATH configuration.
from selenium import webdriver
driver = webdriver.Chrome()
print(driver.capabilities["browserVersion"])
driver.quit()In the example above, webdriver.Chrome() checks the installed Chrome version, downloads the matching ChromeDriver to cache, then launches it. We can see the browser version via driver.capabilities["browserVersion"].
If your team needs full control — for example, pinning a specific driver version in a closed network — download ChromeDriver from the official site and place it in a directory on PATH:
export PATH=$PATH:/opt/chromedriverThe export PATH=$PATH:/opt/chromedriver command adds the driver location to the environment. This setting only applies to the active terminal session; for persistence, add it to ~/.zshrc or ~/.bashrc.
With the driver ready, let's build the first script that interacts with a real page. The selenium.dev site provides a demo form page that's great for practice:
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://www.selenium.dev/selenium/web/web-form.html")
judul = driver.title
print("Judul halaman:", judul)
assert "Web form" in judul
finally:
driver.quit()The try/finally structure ensures driver.quit() always runs, even when the test fails. Without it, the browser can be left behind as a zombie process.
WebDriver isn't limited to Chrome. For Firefox and Edge, just swap the constructor:
from selenium import webdriver
firefox = webdriver.Firefox()
firefox.quit()
edge = webdriver.Edge()
edge.quit()The webdriver.Firefox() command uses GeckoDriver and webdriver.Edge() uses Edge WebDriver — both are also managed automatically by Selenium Manager. We'll cover cross-browser strategies thoroughly in episode 14.
The main rule: the driver must be compatible with the browser version, not the Selenium version. ChromeDriver follows Chrome's major version. If Chrome is updated to a new version without a matching driver, Selenium will throw errors like session not created.
Selenium Manager handles this automatically, but for debugging you can check the versions in use:
google-chrome --version
chromedriver --versionInside a test, you can also verify the browser version programmatically:
from selenium import webdriver
driver = webdriver.Chrome()
caps = driver.capabilities
print(caps["browserName"], caps["browserVersion"])
driver.quit()The output of caps["browserVersion"] can be recorded in test reports. This habit helps teams trace tests broken by browser version changes — one of the topics we'll dive into in episode 19.
Warning
Never mix major versions of browser and driver. If Chrome 130 and ChromeDriver 126 are used together, compatibility errors are almost guaranteed. Rely on Selenium Manager, or pin the versions explicitly.
Episode 3 makes sure the technical foundation runs: adding Selenium and pytest to the project, understanding the role of Selenium Manager and manual driver setup options, launching the first automated browser in Chrome, Firefox, and Edge, and the rules for matching driver versions with browsers.
Key takeaways:
pip freeze > requirements.txt.try/finally or a fixture.In episode 4 next, we'll cover locating elements and interacting with the DOM — locator techniques for id, name, class, CSS selector, and XPath, how to grab elements, click, send text, submit forms, and interact with dropdowns, checkboxes, and radio buttons. This is the most frequently used skill in all of automation.