Skip to main content
SeleniumDecoded

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 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.

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