Every Selenium engineer hits these exceptions. Know what they mean and you'll debug 10x faster.
| Exception | What Happened | How to Fix |
|---|---|---|
| NoSuchElementException | Element not found on the page | Check locator, add explicit wait, check if element is in an iframe |
| StaleElementReferenceException | Page refreshed or DOM changed after you found the element | Re-find the element before interacting with it |
| TimeoutException | Explicit wait timed out | Increase timeout, verify the condition, check page load |
| ElementNotInteractableException | Element exists but can't be clicked (hidden, overlapped) | Scroll to element, wait for visibility, use JS click |
| ElementClickInterceptedException | Another element is covering it (modal, spinner) | Close the overlay, wait for it to disappear |
| NoAlertPresentException | Tried to switch to an alert that doesn't exist | Wrap in try-catch, or wait for alert to appear |
| NoSuchFrameException | Frame doesn't exist or hasn't loaded yet | Verify frame name/id, add wait for frame |
| InvalidSelectorException | Your CSS/XPath has a syntax error | Test the selector in browser DevTools first |
Q: Can Selenium automate desktop applications?
A: No. Selenium is exclusively for web browser automation. For desktop apps, use WinAppDriver (Windows), or tools like AutoIt. For mobile apps, use Appium.
Q: Can Selenium handle CAPTCHA?
A: No. CAPTCHAs are designed to block automation. In test environments, ask the development team to disable CAPTCHA or provide a bypass. Never try to solve CAPTCHAs in automated tests — it defeats their purpose.
Q: What is the difference between isDisplayed(), isEnabled(), and isSelected()?
A: isDisplayed() checks if the element is visible on screen (not hidden by CSS). isEnabled() checks if the element is interactive — an input with disabled attribute returns false. isSelected() checks if a checkbox, radio button, or dropdown option is currently checked/selected.
Q: How do you scroll to an element in Selenium?
A: Two ways: (1) JavascriptExecutor — ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element). (2) Selenium 4 Actions class — new Actions(driver).scrollToElement(element).perform(). The JavaScript approach works across all Selenium versions.
Key Point: Selenium WebDriver is find + interact + verify. Master the locators, handle exceptions gracefully, and always quit the browser.
Answer all 5 questions, then submit to see your score.
1. What is the role of ChromeDriver in the Selenium architecture?
2. What happens when driver.findElement() cannot find the element?
3. How do you safely check if an element exists without throwing an exception?
4. What is the difference between driver.close() and driver.quit()?
5. What must you do before interacting with elements inside an iframe?