In part 7 we take the ideas from earlier instalments and apply them to a larger, messier site. 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.
What to watch for
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.
Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.
Step by step
Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it.
Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.
Key takeaway
Replace sleeps with explicit waits for a specific condition: element visible, text present, or network idle, with a sensible timeout.