Model answers for 4 Selenium questions
Typical round: concepts, framework walkthrough, a live script
Q: Implicit vs explicit wait? A: An implicit wait sets a global timeout for finding elements. An explicit wait, using WebDriverWait with ExpectedConditions, waits for a specific condition like elementToBeClickable. Prefer explicit waits and avoid mixing them with a long implicit wait, which can cause unpredictable delays.
Q: How did you design your framework? A: Java with Selenium 4 and TestNG, Page Object Model for pages, a driver factory with ThreadLocal for parallel runs, config files per environment, test data from Excel or JSON, Extent reports with screenshots on failure, and Jenkins running suites nightly.
Q: How do you handle a StaleElementReferenceException? A: It means the DOM changed after you found the element. Re-locate the element after the page updates, wait for the expected state with an explicit wait, and avoid caching elements across page reloads.
Q: How do you switch to a new window? A: Store the current handle with getWindowHandle(), loop through getWindowHandles(), switch to the one that differs with switchTo().window(), and switch back when done.