> For the complete documentation index, see [llms.txt](https://testingvn.gitbook.io/playwright/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testingvn.gitbook.io/playwright/implement-test-cases/handle-broken-images.md).

# Handle broken images

```typescript
import {test,expect} from '@playwright/test';

test('verify broken image', async ({page}) => {
    await page.goto('/broken_images');
    
    const images = page.locator('img');
    
    // Check if the image is present
    const allImages = await images.all();

    for (const image of allImages) {
        const imgSrc = await image.getAttribute('src');
        expect(imgSrc?.length).toBeGreaterThan(1)
        const res = await page.request.get("https://the-internet.herokuapp.com/"+imgSrc)
        console.log("Image src:", imgSrc);
        expect(res.status()).toBe(200)// Ensure src attribute exists
    }   
});

```
