Python Selenium Architecture
Source: Dev.to
High Level Selenium Architecture
Selenium is a tool to automate web‑based and mobile‑based applications.
For web‑based applications Selenium includes built‑in drivers to communicate with browsers. For mobile applications, Selenium requires an additional source called Appium.
Components
-
Language Binding
This is where automation code is written. Selenium supports languages such as Java, Python, C#, etc. The binding converts code into WebDriver commands and acts as an interface between user code and Selenium. -
Browser Drivers
The middle layer that connects the code to the browser. Examples: ChromeDriver, EdgeDriver, SafariDriver, … -
Browsers
The final execution happens here. Examples: Chrome, Edge, Safari, …

Internal Selenium Architecture

WebDriver Class
The main entry point in Selenium.
from selenium import webdriver
driver = webdriver.Chrome()
It initializes the browser session and sends commands to the Remote WebDriver.
Remote WebDriver
The core component of Selenium. It receives commands from the WebDriver class, converts them to JSON, and forwards the requests to the appropriate browser driver.
Browser Engine
Handles actual rendering, interprets commands, and interacts with the DOM.
Browser Drivers
Bridge Selenium and the browser, executing the instructions within the browser.
Significance of Python Virtual Environment
A Python virtual environment allows developers to manage project dependencies independently. This is especially useful when working on multiple projects with different library requirements—for example, using Selenium 4 in one project and Selenium 3 in another.