Testing / Selenium Interview questions
How can you optimize Selenium test execution time?
Several practical changes compound to meaningfully cut down suite runtime.
- Replace implicit waits with targeted explicit waits, since a blanket implicit wait adds delay to every failed lookup across the whole suite.
- Run in parallel via TestNG/JUnit with a ThreadLocal WebDriver, rather than executing every test sequentially.
- Set up state through direct API or database calls instead of driving the UI for repetitive setup steps like account creation.
- Reuse authentication by injecting a saved session cookie instead of logging in through the UI in every test.
- Run headless on CI, since rendering a full visible window adds overhead with no test-value benefit there.
As with UI-driven setup in general, the biggest single win for most Selenium suites is usually eliminating repeated, slow login flows that get executed at the start of nearly every test.
More Related questions...