UI automation · mid
Selenium 4, Grid and running in parallel
Selenium 4 uses the W3C WebDriver protocol, manages drivers by itself, and adds BiDi. Grid runs many sessions at once, but the code must be safe for it.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Selenium 4 speaks the W3C WebDriver protocol: the client sends HTTP commands to a driver (chromedriver, geckodriver), which controls the browser. The old JSON Wire Protocol is gone.
- Selenium Manager finds the browser, downloads the matching driver and caches it. WebDriverManager is usually not needed. For offline CI, bake drivers and browsers into the image.
- WebDriver BiDi is a two-way W3C protocol over a WebSocket. It gives console logs, JavaScript errors and network interception across browsers. It is turned on with the webSocketUrl capability.
- Grid parts: Router, Distributor, Session Map, New Session Queue, Event Bus and Nodes. Modes: standalone, hub and node, fully distributed.
- Plan capacity with maths: 600 tests on 3 browsers is 1,800 runs. Divide the total browser time by the time you allow to get the number of parallel sessions.
- Docker Selenium needs --shm-size=2g, because the Docker default /dev/shm of 64 MB crashes Chrome.
- In the test code use RemoteWebDriver with options from config, and one driver per thread (ThreadLocal).
- File upload on a Grid: sendKeys(path) needs the file on the node. Use LocalFileDetector so the client sends the file first. Build paths from the project, not from C:\Users.
The red pen
Common traps: mistake → fix
Mistake: Selenium 4 still uses the JSON Wire Protocol
Fix: it uses W3C WebDriver.
Mistake: BiDi works only in Chrome
Fix: it is a cross-browser W3C standard.
Mistake: Just add threads to go faster
Fix: a shared static driver and shared test data will break.
Easy to hard
Questions interviewers ask, easy to hard
- What changed for you in Selenium 4?
- What is Selenium Manager?
- How would you run 600 tests in under 20 minutes?
- A file upload works on your laptop but fails on the Grid. Why?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.