> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FindAll Test Example

> TestDriver SDK - FindAll Coffee Icons Test Loads a random icon grid and uses findAll() to locate and click all 4 coffee cup icons.

## Overview

TestDriver SDK - FindAll Coffee Icons Test Loads a random icon grid and uses findAll() to locate and click all 4 coffee cup icons

Review the source code below to understand the implementation details and patterns used.

## Live Test Run

Watch this test execute in a real sandbox environment:

<iframe src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6a051d022ca563f154801ccc/replay" width="100%" height="600" style={{ border: "1px solid #333", borderRadius: "8px" }} allow="fullscreen" />

## Source Code

```javascript title="findall-coffee-icons.test.mjs" theme={null}
/**
 * TestDriver SDK - FindAll Coffee Icons Test
 * Loads a random icon grid and uses findAll() to locate and click all 4 coffee cup icons
 */

import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

describe("FindAll Coffee Icons", () => {
  it("should find and click all 4 coffee cup icons", async (context) => {
    const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP,
      headless: true,
    });

    await testdriver.provision.chrome({
      url: "https://v0-random-icon-grid.vercel.app/",
    });

    // Use findAll to locate all coffee cup icons on the page
    const coffeeIcons = await testdriver.findAll("coffee cup icon, there are exactly 4 on the page");

    // Log each icon's coordinates
    console.log(`Found ${coffeeIcons.length} coffee icons:`);
    coffeeIcons.forEach((icon, i) => {
      console.log(`  Icon ${i + 1}: (${icon.x}, ${icon.y}) center=(${icon.centerX}, ${icon.centerY})`);
    });

    // Verify we found 3 or 4 coffee icons
    expect(coffeeIcons.length).toBeGreaterThanOrEqual(3);
    expect(coffeeIcons.length).toBeLessThanOrEqual(4);

    // Click each coffee cup icon
    for (const icon of coffeeIcons) {
      await icon.click();
    }

    // Verify the selection count is displayed
    await testdriver.assert("the page says 'Selected: 3 / 4' or 'Matched 4 of a kind!'");
  });
});
```

## Running This Example

```bash theme={null}
# Clone the TestDriver repository
git clone https://github.com/testdriverai/testdriverai

# Install dependencies
cd testdriverai
npm install

# Run this specific example
npx vitest run examples/findall-coffee-icons.test.mjs
```

<Note>
  Make sure you have `TD_API_KEY` set in your environment. Get one at [testdriver.ai](https://testdriver.ai).
</Note>
