{"data":{"id":74,"slug":"testing-login-flows-end-to-end-part-4-74","title":"Testing login flows end to end, part 4","excerpt":"Part 4 looks at what changes when the same technique has to run every day in production. A login form is a small piece of UI with a surprising number of paths through it: success, wrong password,…","seriesName":"Testing login flows end to end","seriesPart":4,"sections":[{"heading":"Introduction","paragraphs":["Part 4 looks at what changes when the same technique has to run every day in production. A login form is a small piece of UI with a surprising number of paths through it: success, wrong password, locked account, slow responses and expired forms."]},{"heading":"Putting it into practice","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.","Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream."]},{"heading":"A practical approach","paragraphs":["Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it.","Always identify your client honestly with a descriptive User-Agent, and keep your request rate modest. A crawler that behaves like a considerate visitor is far less likely to cause problems for the site operator."]},{"heading":"Key takeaway","paragraphs":["Cover each account state with its own test, assert on visible messages and on the resulting URL, and give slow paths an explicit, generous timeout."]}],"authorId":8,"authorName":"Hannah Novak","authorSlug":"hannah-novak","category":"Testing","tags":["selenium","ethics","scrapy"],"publishedAt":"2024-01-11T00:00:00.000Z","wordCount":180,"readingTimeMinutes":2}}