Frequently Asked Questions
Common questions about Selenium and test automation
Getting Started
What programming languages can I use with Selenium?
Selenium WebDriver officially supports Java, Python, C#, Ruby, JavaScript (Node.js), and Kotlin. All tutorials on this site include examples in Java, Python, JavaScript, and C#.
Do I need to install browser drivers manually?
With Selenium 4, the built-in Selenium Manager automatically downloads and manages browser drivers for you. For Selenium 3, you need to manually download the appropriate driver (ChromeDriver, GeckoDriver, etc.) for your browser.
What is the difference between Selenium 3 and Selenium 4?
Selenium 4 introduced several improvements: native Selenium Manager for driver management, W3C WebDriver protocol support, relative locators, improved grid architecture, and better documentation. Most existing Selenium 3 code works with minimal changes in Selenium 4.
Is Selenium free to use?
Yes, Selenium is completely free and open source under the Apache 2.0 license. You can use it for personal projects, commercial applications, and enterprise testing without any cost.
Locators & Elements
What is the best locator strategy?
The recommended order of preference is: ID (fastest and most reliable), name, CSS selector, and XPath. Use IDs when available, CSS selectors for complex queries, and XPath only when CSS cannot achieve what you need (like selecting by text content).
How do I find elements inside iframes?
You must first switch to the iframe using driver.switchTo().frame(), then locate elements within it. Remember to switch back to the default content using driver.switchTo().defaultContent() when done.
Why does my locator work in DevTools but not in Selenium?
Common causes include: timing issues (element not loaded yet), dynamic IDs or classes that change, elements inside iframes or shadow DOM, or the page being in a different state. Use explicit waits and verify your locator is unique.
How do I find elements inside Shadow DOM?
Locate the host element, call getShadowRoot() (Selenium 4) to get the shadow tree as a search context, and use CSS selectors from it. Repeat for nested hosts. XPath cannot cross shadow boundaries and closed shadow roots are not reachable.
What is the best attribute to locate elements by?
A dedicated test attribute such as data-testid. It exists only for tests, so nobody changes it for styling reasons. Agree a naming convention with developers and enforce it in code review; it removes most locator maintenance.
How do I handle dynamic elements?
Use explicit waits (WebDriverWait) to wait for elements to be present, visible, or clickable. Avoid using dynamically generated IDs or classes. Instead, use stable attributes or relative XPath/CSS selectors.
Waits & Timing
What is the difference between implicit and explicit waits?
Implicit waits apply globally to all findElement calls and wait for elements to appear. Explicit waits are applied to specific conditions and can wait for visibility, clickability, or custom conditions. Do not mix both types as it can cause unpredictable timing issues.
Why is Thread.sleep() bad practice?
Thread.sleep() always waits the full duration even if the element is ready sooner, wasting time. It also fails if the element takes longer than expected. Use explicit waits instead, which poll for conditions and proceed as soon as they are met.
How do I wait for page load to complete?
Wait for document.readyState to be "complete" using JavaScript executor, or wait for specific elements that indicate the page is fully loaded. For AJAX-heavy pages, wait for specific elements or network idle state.
Selenium 4, BiDi and the Future
What is the latest version of Selenium?
Selenium 4.48.0, released on 27 August 2026, is the current stable release across Java, Python, JavaScript, .NET and Ruby. Selenium releases roughly monthly; the Releases & News page on this site tracks each one with its breaking changes.
Is Selenium 5 out yet?
No. As of September 2026 the stable line is 4.x. Alpha builds of Selenium 5 are planned, and the published direction is to remove CDP-only code paths in favour of WebDriver BiDi. Java 17 as a minimum is under discussion for that release.
What is WebDriver BiDi and should I use it?
BiDi is the W3C bidirectional protocol that adds a WebSocket next to classic WebDriver so the browser can push events (console logs, JavaScript errors, network requests) and accept interception commands. Enable it with one capability and use it for error capture, basic auth, request blocking and mocking. It works across Chrome, Edge and Firefox; Safari support is in Technology Preview since 4.47.
Is CDP (Chrome DevTools Protocol) deprecated in Selenium?
CDP still works on Chromium browsers but is version-locked and Chromium-only. Firefox CDP support was removed in Selenium 4.29. The Selenium 5 roadmap removes CDP-only code paths. Use BiDi for anything it covers and keep CDP only for Chromium-specific features such as performance metrics.
Which Java, Python and .NET versions does Selenium 4 require?
Java 11 or newer (Java 8 support ended at 4.13). Python 3.10 or newer (3.9 support ended in late 2025 with 4.37). .NET 8 or .NET Framework 4.6.2 via netstandard2.0, with strongly signed assemblies since 4.44. Node.js 18 or newer for the JavaScript bindings.
Selenium or Playwright?
Choose by team language, browser and device matrix, existing infrastructure and wait discipline. Selenium leads on language breadth, vendor-maintained real browsers, Grid scale and mobile via Appium; Playwright leads on speed and built-in auto-wait for JavaScript-first teams. In 2026 Playwright leads new-project adoption while Selenium retains the largest installed base. Our comparison lesson goes into detail.
Can I use AI with Selenium?
Yes, in specific ways: generating page objects from real DOM with review, self-healing locators with every heal logged and fixed in source, visual AI for screenshot comparison, and LLM triage over evidence collected via BiDi. Autonomous test generation is not yet reliable enough for regression suites.
Grid, Docker and CI
Why does Chrome crash with "session deleted because of page crash" in Docker?
The container default /dev/shm of 64 MB is too small for Chrome. Run with --shm-size=2g (or pass --disable-dev-shm-usage to Chrome). The official Selenium images document this requirement.
How do I run Selenium Grid on Kubernetes?
Use the official Helm chart from docker-selenium. Since Grid 4.41 the KubernetesSessionFactory provisions a browser Pod per session with no Docker daemon, and KEDA autoscales nodes from queue length. Redis-backed session state (4.44 and 4.45) provides high availability.
How do I upload or download files through a Grid?
Uploads: set LocalFileDetector on RemoteWebDriver so sendKeys transfers the file to the browser machine. Downloads: enable managed downloads on nodes and the se:downloadsEnabled capability, then fetch files with getDownloadableFiles and downloadFile. Selenium 4.48 extended this to Kubernetes and relay sessions.
Should I use a cloud grid or host my own?
Cloud for breadth (Safari, real devices, every browser version) and speed to start; self-hosted Docker or Kubernetes Grid for high volume, low latency and data locality. Many teams run pull-request Chrome suites on their own Grid and the nightly cross-browser matrix in the cloud.
How do I avoid Docker Hub rate limits for Selenium images?
Since April 2026 the official images are mirrored to GitHub Container Registry under ghcr.io/seleniumhq with identical tags.
Common Errors
What does "Element not interactable" mean?
The element exists in the DOM but cannot be clicked/typed into. Common causes: element is hidden, covered by another element, or has zero dimensions. Try scrolling to the element, waiting for it to be clickable, or using JavaScript executor.
What does "Stale Element Reference" mean?
The element reference is no longer valid because the DOM has changed (page refresh, AJAX update, navigation). Re-locate the element after any DOM changes, or use a fresh locator call instead of storing element references.
Why does my test work locally but fail in CI/CD?
Common causes: missing browser/driver in CI environment, different screen resolution, slower execution environment, timing issues. Use headless mode, ensure drivers are installed, add proper waits, and consider using a cloud testing service.
How do I handle "Element click intercepted" errors?
Another element is covering your target element (often a modal, overlay, or sticky header). Wait for overlays to disappear, scroll the element into view, or use JavaScript click as a last resort.
Best Practices
What is the Page Object Model?
POM is a design pattern where each web page is represented by a class. The class contains locators and methods for interacting with that page. This improves maintainability, reduces code duplication, and makes tests more readable.
Should I run tests in headless mode?
Headless mode is faster and great for CI/CD pipelines. However, run tests in headed mode during development for debugging. Some interactions behave slightly differently in headless mode, so occasionally verify with a visible browser.
How many assertions should I have per test?
Aim for one logical assertion per test (testing one thing). However, multiple related assertions in a single test are acceptable if they verify different aspects of the same feature or reduce test execution time significantly.
Should I use absolute or relative XPath?
Always use relative XPath (starting with // instead of /html/body/...). Absolute XPath is extremely fragile and breaks with any DOM structure change. Relative XPath with specific attributes is more maintainable.
This Website
What programming languages are covered in the tutorials?
All tutorials include code examples in Java, Python, JavaScript (Node.js with selenium-webdriver), and C#. You can switch between languages with a single click in any code example.
Is this content suitable for beginners?
Yes! We start from the basics with setup guides and your first test. Each topic builds on previous knowledge, and content is organized from beginner to advanced. Badges indicate difficulty and Selenium version compatibility.
How do I report an error or suggest content?
Please open an issue on our GitHub repository or send us feedback through our contact form. We appreciate corrections, suggestions for new topics, and any feedback to improve the content.
Is this affiliated with the Selenium project?
No, Selenium Decoded is an independent educational resource and is not officially affiliated with the Selenium project. For official documentation, visit selenium.dev.
Didn't find your answer?
Check out our detailed tutorials or search the documentation