Chapter 02Lesson 03~120 minutes

Selenium Ecosystem, Installation, and First WebDriver Session: Configuration, Design Patterns, and Trade-Offs

Move beyond “it launches” and choose an installation/session strategy based on reproducibility, diagnostics, security, portability, and CI behavior.

Design choicesManager vs manualHeadlessPinningPortability

Learning objectives

  • Compare Selenium Manager with explicitly managed driver services without treating either as universally correct.
  • Distinguish a system-installed browser from a browser version managed through Selenium Manager.
  • Explain headed versus headless execution as a browser-mode choice, not a guarantee of CI equivalence.
  • Choose dependency pinning and upgrade policy appropriate to release evidence.
  • Use one primary binding for coherent teaching while recognizing cross-binding lifecycle equivalence.
  • Produce a decision record that ties configuration choices to observable session evidence.

1. Automatic Manager versus explicit driver service

Selenium Manager default: minimal project configuration, less manual browser/driver drift, built-in cache and resolution, and consistent behavior across the core bindings. This is the best Chapter 02 default.

Explicit driver service: useful when an organization distributes a reviewed driver binary, a hermetic build image already contains a driver, or diagnostic policy requires an exact executable and service log. The tradeoff is ownership: once you provide the executable path, your environment is responsible for keeping it compatible.

from selenium import webdriver

# Default management path: binding can invoke Selenium Manager.
driver = webdriver.Chrome()
driver.quit()

# Explicit path: your environment owns this executable/version.
service = webdriver.ChromeService(executable_path="/approved/tools/chromedriver")
driver = webdriver.Chrome(service=service)
driver.quit()
Do not copy the explicit path literally. It is an architecture example. Never commit a personal absolute path into a shared course/project. Use an approved, documented path or environment-specific configuration if manual management is required.

2. System browser versus Selenium-Manager-managed browser

Using the system browser is simple and mirrors what developers already run, but evergreen browser updates can change the environment between test runs. Selenium Manager can also manage Chrome, Firefox, and Edge browser releases and supports browser-version requests such as fixed major versions or channel labels where applicable. That can improve controlled compatibility testing, but it may download large browser assets and introduces cache/network governance.

from selenium import webdriver

options = webdriver.ChromeOptions()
options.browser_version = "stable"   # current stable channel request

driver = webdriver.Chrome(options=options)
print(driver.capabilities.get("browserVersion"))
driver.quit()

The capability request does not excuse you from recording the returned version. In CI, decide whether browser rollout should follow the host image, a managed browser label, or a pinned image/version policy. Make that an explicit platform decision rather than letting developer laptops define the release matrix.

3. Headed versus headless

Headed execution is valuable while learning, debugging rendering/focus behavior, and watching the first workflow. Headless execution reduces display-server requirements and is common in CI, but it is still a real browser mode with its own environment, viewport, GPU, font, extension, and policy conditions. A test that passes headed and fails headless is not automatically “a Selenium bug”; compare the actual browser arguments, viewport, rendering resources, and application evidence.

Keep the mandatory Chapter 02 path headed unless your environment cannot display a browser. Headless flags are browser-vendor behavior and can evolve, so verify the current browser documentation before standardizing a flag across a fleet.

4. Pin binding dependencies; manage browser upgrades intentionally

selenium==4.47.0 makes the Python API surface reproducible for this chapter. Floating pip install -U selenium in every CI run can change client behavior without a code review. Conversely, freezing a browser forever can hide compatibility regressions and create security risk. Mature teams separate those concerns:

  • pin project dependencies in reviewed files;
  • upgrade Selenium deliberately with changelog review;
  • define browser channels/versions in the test-platform contract;
  • record returned browser/driver capabilities on every run;
  • exercise browser upgrades in a controlled compatibility job before changing release gates.

5. One primary teaching binding versus cross-binding comparison

Python is the primary binding for this course chapter so the learner can focus on browser semantics rather than language syntax. The core lifecycle is shared across supported bindings: create options/service as needed, create a driver/session, send commands, inspect results, and quit. Method names and framework integration differ, and some new features reach bindings at different times. Cross-binding snippets should therefore clarify a real portability issue—not multiply every example five times.

Concern Python Java JavaScript Meaning
Create local Chrome webdriver.Chrome() new ChromeDriver() new Builder().forBrowser('chrome').build() Negotiate a WebDriver session
Close session driver.quit() driver.quit() await driver.quit() Terminate session/browser ownership
Dependency pin requirements.txt Maven/Gradle package.json Project-level client provenance

6. Worked decision table

The following table organizes the key choices and evidence for Worked decision table. Use it together with the surrounding prose so the rows serve as a comparison aid rather than standalone rules.

Scenario Recommended starting choice Evidence to retain Main risk
Developer learning locally Manager + installed stable browser + headed binding/browser/driver capabilities machine drift
Hermetic CI image with reviewed driver explicit Service may be appropriate image digest, driver/browser versions, service log manual mismatch during upgrades
Cross-version compatibility job managed/requested browser version or controlled image requested and returned browser version cache/network/image availability
Corporate egress proxy Manager with approved proxy/mirror policy sanitized Manager diagnostics credentials/TLS policy leakage
Headless CI headless only after headed baseline is known browser args, viewport, platform, screenshot environment-specific rendering difference

7. Design exercise

For each of these environments—developer laptop, locked-down corporate workstation, Linux CI runner, and a future Grid node—write a six-line configuration decision record:

  1. binding/version policy;
  2. browser source/version policy;
  3. driver management owner;
  4. network/proxy/cache assumptions;
  5. headed/headless mode and why;
  6. evidence required before a browser failure can be triaged.

Do not choose “latest everywhere” as a substitute for policy. “Latest” changes over time; a production record needs a review/update mechanism.

Knowledge check

When is an explicit ChromeService executable path reasonable?

Does options.browser_version = "stable" prove the exact browser version used?

Why not float the Selenium dependency on every CI run?

Is headless execution a different testing tool?

Why keep one primary binding in beginner lessons?

Next lesson

Diagnose startup failures without guessing

Lesson 4 turns driver/browser/Manager/session failures into an evidence-first diagnostic sequence and a reversible broken-driver experiment.

Official references and version notes

Version and compatibility note

Version-sensitive behavior was rechecked against current Selenium primary documentation on 2026-08-27. The mandatory path pins the Python binding to Selenium 4.47.0, requires Python 3.10+, uses one supported local Chromium-family browser for the runnable workflow, relies on Selenium Manager as the default driver-management path, and targets only a loopback fixture. The exact browser and driver versions are intentionally discovered from the created session rather than hard-coded. Selenium Grid, WebDriver BiDi, paid browser clouds, enterprise identity, and hosted CI are not required in Chapter 02.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.