{"data":{"id":50,"slug":"choosing-css-selectors-that-survive-redesigns-part-3-50","title":"Choosing CSS selectors that survive redesigns, part 3","excerpt":"In part 3 we take the ideas from earlier instalments and apply them to a larger, messier site. A selector that worked yesterday and fails today is usually a selector that depended on something nobody…","seriesName":"Choosing CSS selectors that survive redesigns","seriesPart":3,"sections":[{"heading":"Introduction","paragraphs":["In part 3 we take the ideas from earlier instalments and apply them to a larger, messier site. A selector that worked yesterday and fails today is usually a selector that depended on something nobody promised to keep the same, such as a generated class name or the position of a div."]},{"heading":"Putting it into practice","paragraphs":["Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it.","Read the site's terms of service before you start. Many sites welcome automated access within limits and say so explicitly; others ask you to use an API instead.","Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them."]},{"heading":"A practical approach","paragraphs":["Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.","Deduplicate as you go. The same item often appears on several listing pages, and a stable identifier such as a SKU or ID makes duplicates easy to spot."]},{"heading":"Key takeaway","paragraphs":["Prefer data-testid attributes, ARIA roles and visible labels. Avoid long chains of nth-child and anything that looks like a hash."]}],"authorId":3,"authorName":"Priya Nakamura","authorSlug":"priya-nakamura","category":"Testing","tags":["selenium","python"],"publishedAt":"2025-02-08T00:00:00.000Z","wordCount":191,"readingTimeMinutes":2}}