{"data":{"id":30,"slug":"choosing-css-selectors-that-survive-redesigns-part-2-30","title":"Choosing CSS selectors that survive redesigns, part 2","excerpt":"This is part 2 of our series, and this time we focus on edge cases readers asked about. 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":2,"sections":[{"heading":"Introduction","paragraphs":["This is part 2 of our series, and this time we focus on edge cases readers asked about. 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":["Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.","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.","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":"Step by step","paragraphs":["Store raw responses alongside parsed output while you are developing. When a parser breaks, you can replay the saved HTML instead of hitting the site again.","Treat HTTP 429 responses as a signal, not an obstacle. Read the Retry-After header, back off, and resume at a slower pace."]},{"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":5,"authorName":"Chen Patel","authorSlug":"chen-patel","category":"Testing","tags":["testing","scrapy","selenium"],"publishedAt":"2026-08-26T00:00:00.000Z","wordCount":209,"readingTimeMinutes":2}}