{"data":{"id":166,"slug":"waiting-strategies-in-selenium-part-9-166","title":"Waiting strategies in Selenium, part 9","excerpt":"For part 9, we revisit the basics with a fresh example and a few lessons learned the hard way. Most flaky Selenium tests are timing problems in disguise. The element exists, just not yet, and a fixed…","seriesName":"Waiting strategies in Selenium","seriesPart":9,"sections":[{"heading":"Introduction","paragraphs":["For part 9, we revisit the basics with a fresh example and a few lessons learned the hard way. Most flaky Selenium tests are timing problems in disguise. The element exists, just not yet, and a fixed sleep is either too short on a slow day or wastes time on a fast one."]},{"heading":"Step by step","paragraphs":["Dynamic pages render content after the initial HTML arrives. A browser automation tool can wait for a specific element to appear, which is far more reliable than sleeping for a fixed amount of time.","Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist."]},{"heading":"Common pitfalls","paragraphs":["Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.","Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them."]},{"heading":"Key takeaway","paragraphs":["Replace sleeps with explicit waits for a specific condition: element visible, text present, or network idle, with a sensible timeout."]}],"authorId":5,"authorName":"Chen Patel","authorSlug":"chen-patel","category":"Browser Automation","tags":["selenium","testing","scrapy","playwright"],"publishedAt":"2025-02-09T00:00:00.000Z","wordCount":173,"readingTimeMinutes":2}}