A common picture of Selenium: your script reaches into the browser and presses buttons. It is a comfortable picture and it is wrong, in a way that matters the first time something breaks. Your script never touches the browser. It sends messages to another program, and that program touches the browser. Once you see the chain, a lot of baffling errors stop being baffling.
The chain, link by link
When your test calls a method to click a button, four things happen.
- The language binding (Java, Python, C# and others) turns your call into an HTTP request carrying JSON.
- That request goes to a driver process, such as ChromeDriver for Chrome, GeckoDriver for Firefox or EdgeDriver for Edge. The driver is a small web server, usually on a local port.
- The driver translates the request into the browser’s own control mechanism and makes the browser perform the action.
- The result travels back the same way, as an HTTP response your binding turns into a return value or an exception.
The language between your code and the driver is the W3C WebDriver protocol, a published standard. Selenium 4 speaks the W3C dialect, and the browser vendors maintain their own drivers against it. This is why the same protocol can be implemented for browsers from different companies, and why tools other than Selenium, including Appium for mobile, reuse it.
Myth: the failure is in my test
With the chain in mind, sort common errors by where they happen.
“This version of ChromeDriver only supports Chrome version N” is a mismatch between link 2 and the browser in link 3. Chrome updated itself overnight and the driver did not. Recent Selenium versions include Selenium Manager, which finds or downloads a matching driver for you, so teams that still pin a driver binary by hand carry a chore the tool can remove. Selenium Manager arrived in version 4.6.
“Session not created” means the driver could not start or attach to a browser: the wrong binary path, a browser that is missing, a sandbox restriction in a container, or a profile directory in use. Nothing in your test logic is involved.
A NoSuchElementException is different: the chain worked, the browser answered, and the answer was “no element matches”. That one is about your locator or your timing.
And a read timeout between your code and the driver tells you that a request was sent and no answer came back in time, perhaps because the page was busy or the browser hung.
Sorting errors this way saves hours. Ask “which link failed?” before you edit the test.
Myth: every command is instant
Each command is a network round trip, even on the same machine. Locating an element and then reading its text is two requests. On a local run that is fractions of a millisecond to a few milliseconds of overhead. Point the same test at a remote machine across a slow link and each of the hundreds of commands in a long test pays the latency. A test with 400 commands and 80 ms per round trip spends 32 seconds just talking. This is one reason remote cloud runs are slower than local ones, and why chatty test code, with needless element lookups, hurts more there.
It also explains why waits are implemented as repeated polling. An explicit wait keeps asking the driver, element by element, until a condition holds or a timeout expires. The implicit wait is a driver-level setting. Mixing implicit and explicit waits is discouraged in Selenium’s own documentation because the timeouts can combine unpredictably.
Myth: Grid is a different tool
Selenium Grid is the same idea with a switchboard in front. Instead of your script talking to a driver on its own machine, it talks to a Grid endpoint using the same protocol, and Grid decides which machine and browser should serve the session. A test only changes where it connects, through a remote driver object and a set of requested capabilities such as browser name and platform.
In Selenium 4, Grid has named parts. The router receives requests. The distributor finds a node with a free slot matching the capabilities. The session map remembers which node holds which session. Nodes are the machines or containers that actually run browsers with their drivers. An event bus lets the components communicate. You can run all of it in one process for small setups, or separate the pieces for scale. Grid can also be deployed on Docker or Kubernetes, which is common when teams want browsers that start fresh for each test.
Grid’s value is parallelism and breadth: running 20 tests at once, or covering several browser and version combinations. Its limits are worth stating. A session occupies a slot for as long as it lives, so a test that forgets to quit the driver hogs capacity until the session times out. Nodes need updates when browsers update. And tests must be independent for parallel runs to be reliable, a point covered in discussions of shared state.
What to take into your next debugging session
Turn on driver logging when a failure is mysterious. The driver log shows every request it received and every command it issued, which tells you whether your click was ever sent. Keep browser, driver and Selenium versions in view, and know which of them auto-updates. Always quit the session in a teardown step, including on failure, or you will leak browser processes on CI machines.
Newer tools such as Playwright talk to the browser through a different channel and skip the separate driver step, which is part of why they behave differently under load. Selenium’s own newer BiDi work moves in a similar direction. But the principle holds across all of them: your script is a client, and something else is driving. Debug the layer that failed.
Figures and names in the examples are illustrative.
Leave a Reply