Automation Framework Releted InterView Questions, Automation Maintenance & Troubleshooting
Automation Maintenance & Troubleshooting
1. Script fails only in Jenkins but works locally – why?
Environment differences are the main culprit. Jenkins often runs:
- Headless mode – different browser behaviour.
- Different browser version / driver – mismatch with local.
- File paths – absolute paths that don’t exist on Jenkins.
- Missing environment variables or permissions.
- Timing – slower CI server needs longer waits.
Debug: Check Jenkins console logs, headless rendering, use same browser/driver versions, make paths relative, and add explicit waits.
2. How do you debug a flaky test?
Flaky test = passes/fails inconsistently without code changes. Steps:
- Analyze logs, screenshots, and failure patterns.
- Identify timing issues → replace
Thread.sleepwith explicit waits. - Check locator stability (avoid index‑based XPath).
- Verify test data isolation (no conflicts).
- Add retry mechanism (TestNG retry analyzer) as temporary measure while fixing.
3. How do you reduce automation execution time?
- Parallel execution – TestNG / Selenium Grid.
- Optimize locators – ID > CSS > XPath.
- Remove static waits – use explicit waits only.
- Headless mode – runs faster without GUI.
- Group tests – run smoke/regression separately.
4. How do you decide what to automate?
Automate tests that are:
- Stable (not changing frequently).
- Repetitive – regression, smoke, critical workflows (login, payment).
- High business impact – core features.
- Time‑consuming when done manually.
5. What tests should NOT be automated?
- Frequently changing UI (until stable).
- One‑time / exploratory tests.
- Usability, visual design (human judgment).
- Tests with high maintenance cost but low ROI.
6. How do you handle frequent UI changes?
Page Object Model centralizes locators. When UI changes:
- Update locator in the page class only – tests untouched.
- Use robust locators: IDs, data‑attributes, relative XPath with contains().
- If changes are too frequent, delay automation until UI stabilizes.
7. How do you maintain an automation suite long‑term?
- Clean code – POM, utilities, external data.
- Regular refactoring – remove dead code, update locators.
- Version control + code reviews.
- Monitor flaky tests and fix promptly.
- Keep framework dependencies updated (Selenium, drivers).
8. Tell me a real automation challenge you faced and solved
Challenge: Automating a page where elements loaded dynamically after AJAX calls. The script often failed because the element existed in DOM but wasn’t clickable – leading to ElementClickInterceptedException.
Solution: Replaced implicit waits with explicit waits that waited for the element to be clickable. Also added a small JavaScript executor to scroll the element into view before clicking. This reduced flakiness by 90% and made the suite reliable.
WebElement btn = wait.until(ExpectedConditions.elementToBeClickable(By.id("submit")));
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", btn);
btn.click();
Comments
Post a Comment