Broken links practice website
Practice finding broken links, locating a link with no text and one padded with spaces, and checking a file download. Two links in the list answer HTTP 404 on purpose. Open the shop catalog
Find the broken linksTwo of these five links answer 404.
Built to break
Link padded with spaces
Built well
Built to break
File download
Built well
Built to break
How to locate Broken links
A link is two things: what it says and where it goes
Broken-link checks are a request problem, not a click problem. Clicking every link is slow and leaves the page; the usual approach is to collect each link’s href, request it, and flag any status of 400 or higher. Two links in the first list point at pages that don’t exist, so corlabs.dev answers 404.
Link text matters for locators too. “Click here” and “here” say nothing about the destination, so a test ends up matching on href or position. Icon-only links have no text at all; a well-built one carries an aria-label that becomes its accessible name.
Whitespace is the other trap. Markup often pads link text with spaces and line breaks, so an exact text match fails while normalize-space() or a tool’s accessible name matching succeeds.
Downloads can’t be checked by looking at the page afterwards. Each tool exposes the download as an event or a file: wait for it, then check its name or contents.
What a stable locator looks like
Find links by their accessible name: visible text, or aria-label for icon links. For broken-link checks, request the href rather than clicking. For downloads, wait for the download event and assert on the file.
// Request every link in the list; two answer 404
const hrefs = await page.getByTestId('link-list').locator('a')
.evaluateAll((links) => links.map((a) => a.href));
for (const href of hrefs) {
const res = await page.request.get(href);
expect.soft(res.status(), href).toBeLessThan(400);
}
await expect(page.getByRole('link', { name: 'Open cart' })).toHaveAttribute('href', '/practice/shop/cart');
await expect(page.getByTestId('track-order')).toHaveText('Track my order');
const [download] = await Promise.all([
page.waitForEvent('download'),
page.getByTestId('download-orders').click(),
]);
expect(download.suggestedFilename()).toBe('orders-sample.csv');In a real workflow
Every shop page links to its cart, order history and element pages; run the broken-link check across the whole shop once the list here passes.
COR Lens generates locators for shadow DOM, iframes and tables, and grades each one. Click the broken links above with it and compare its pick with yours.
Add to Chrome