Basic Selenium questions
1. What are the components of Selenium?
Selenium WebDriver (browser automation API), Selenium IDE (record and playback browser extension) and Selenium Grid (runs tests in parallel across machines and browsers).
2. Which locators does Selenium support?
id, name, className, tagName, linkText, partialLinkText, cssSelector and xpath. Prefer stable ids or data-test attributes and CSS selectors; avoid long absolute XPaths.
3. findElement vs findElements?
findElement returns the first matching element or throws NoSuchElementException. findElements returns a list, which is empty when nothing matches, so it is useful for checking that an element is absent.
Intermediate Selenium questions
4. Implicit vs explicit vs fluent wait?
An implicit wait sets a global timeout for finding elements. An explicit wait (WebDriverWait with ExpectedConditions) waits for a specific condition such as visibility or clickability. A fluent wait is an explicit wait with a custom polling interval and ignored exceptions. Do not mix implicit and explicit waits.
5. What is the Page Object Model?
POM creates one class per page that holds its locators and actions. Tests call methods such as loginPage.login(user) instead of raw locators, so a UI change is fixed in one place and tests read clearly.
6. How do you handle alerts, frames and windows?
driver.switchTo().alert() to accept or dismiss alerts, switchTo().frame() by index, name or element for iframes, and getWindowHandles() with switchTo().window(handle) for new tabs or windows. Switch back with defaultContent() or the original handle.
7. What causes StaleElementReferenceException?
The element was found earlier but the DOM changed (page refresh or re-render), so the reference is no longer attached. Find the element again after the change or wait for the new element before acting.
8. How do you run tests in parallel?
Use TestNG's parallel attribute in testng.xml or JUnit 5 parallel execution, keep a separate WebDriver per thread (ThreadLocal), and use Selenium Grid or a cloud grid to run across browsers.
Advanced Selenium questions
9. Describe a hybrid automation framework you would build.
Java or Python with Selenium, TestNG or pytest, the Page Object Model, data-driven tests from Excel or JSON, config files for environments, reusable utilities, reports (Extent or Allure), screenshots on failure, Maven or Gradle builds and a CI pipeline in Jenkins or GitHub Actions.
10. Selenium vs Playwright?
Selenium supports many languages and browsers and has a huge ecosystem through the WebDriver protocol. Playwright drives browsers over its own protocol with auto-waiting, network interception, tracing and parallel test isolation built in, which usually means faster and less flaky tests.
Want to practise these with a trainer? APEX live batches include mock interviews, real projects and placement support. See upcoming batches.
