Home › Software Testing › Software Testing › tools_automation_cicd › Which is a best practice for stable Selenium scr…
Which is a best practice for stable Selenium scripts?
AAvoid running tests in headless browsers
BUse explicit waits for specific conditions
CUse Thread.sleep generously between actions
DHardcode all element locators in tests
Answer & Solution
Correct answer: B. Use explicit waits for specific conditions
Explicit waits (until condition) are robust against timing variance. Thread.sleep is brittle (too short fails; too long wastes time). Hardcoded locators hurt maintainability. Headless mode is actually preferred for CI.
Related questions
In Scrum, the 'Definition of Done' (DoD) typically includesTest pyramid (Mike Cohn) advocates forA 'flaky test' is a test thatBehaviour-driven development (BDD) tools commonly usePerformance testing in general is BROADER than load testing because it includesAccessibility testing primarily ensures thatPenetration testing is a form ofMutation testing measures the effectiveness of