Testing / Selenium Interview questions
Explain the execution flow of a Selenium test?
A typical Selenium test run moves through setup, execution, and teardown phases, usually orchestrated by the paired test framework rather than Selenium itself.
flowchart TD
A[Test framework starts test method] --> B[Instantiate WebDriver, launch driver executable]
B --> C[Browser session opens]
C --> D[Navigate and locate elements]
D --> E[Perform actions and assertions]
E --> F{Passed?}
F -->|Yes| G[driver.quit in teardown]
F -->|No| H[Capture screenshot/log, then teardown]
H --> G
G --> I[Report results via framework listener]
Because Selenium has no built-in per-test isolation like a fresh browser context, the test framework's @BeforeMethod/@AfterMethod (or equivalent) hooks are what's actually responsible for creating a new driver instance before each test and quitting it afterward - skipping proper teardown is a common way stale sessions and state leak between what should be independent tests.
More Related questions...