Selenium error NoSuchElementException: no such element: Unable to locate element
Selenium searched the current DOM for your locator and found nothing, and either the selector is wrong or the element hasn't rendered yet.
Why this happens
- The locator (CSS/XPath/id) is incorrect or has changed since the test was written
- The element renders asynchronously and the test looked for it before the page finished loading
- The element is inside an `<iframe>`, which Selenium doesn't search into without an explicit frame switch
How to fix it
- Verify the locator against the live page in devtools before assuming the code is wrong
- Add an explicit wait for presence: `new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.presenceOfElementLocated(by))`
- For elements inside iframes, call `driver.switchTo().frame(...)` first