> ## 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.

# doubleClick()

> Double-click an element you found, for example to open a file or select a word.

Double-click an element you've located with [`find()`](https://docs.testdriver.ai/find):

```javascript theme={null}
await testdriver.find('report.pdf in the file list').doubleClick();
```

## element.doubleClick()

Double-clicks the element at the point where `find()` located it. It's the same as `element.click('double-click')`.

```typescript theme={null}
element.doubleClick(): Promise<void>
```

It takes no parameters.

### Errors

Throws an `ElementNotFoundError` if `find()` didn't locate the element. See [click()](https://docs.testdriver.ai/click.md#errors) for how to check `found()` first.

## Double-click at coordinates

The client has no `doubleClick()` method. To double-click a point on the screen, pass `action: 'double-click'` to [`testdriver.click()`](https://docs.testdriver.ai/click#testdriver-click-options):

```javascript theme={null}
await testdriver.click({ x: 640, y: 360, action: 'double-click' });
```

Prefer `element.doubleClick()`, which keeps working when the layout or screen size changes.

## Examples

### Open a file in VS Code

```javascript theme={null}
await testdriver.find('package.json in the Explorer sidebar').doubleClick();
await testdriver.assert('package.json is open in the editor');
```

### Select a word

```javascript theme={null}
await testdriver.find('the word "Checkout" in the page heading').doubleClick();
await testdriver.pressKeys(['ctrl', 'c']);
```

## Complete example

```javascript tests/open-file.test.mjs theme={null}
import { describe, expect, it } from 'vitest';
import { TestDriver } from 'testdriverai/vitest/hooks';

describe('VS Code', () => {
  it('opens a file from the Explorer', async (context) => {
    const testdriver = TestDriver(context);
    await testdriver.exec({
      language: 'sh',
      code: 'mkdir -p /tmp/my-project && echo "{}" > /tmp/my-project/package.json',
    });
    await testdriver.provision.vscode({ workspace: '/tmp/my-project' });

    await testdriver.find('package.json in the Explorer sidebar').doubleClick();

    const result = await testdriver.assert('package.json is open in the editor');
    expect(result).toBe(true);
  });
});
```

## Related

* [click()](https://docs.testdriver.ai/click.md): single clicks, and clicks at coordinates
* [rightClick()](https://docs.testdriver.ai/right-click.md): open a context menu
* [find()](https://docs.testdriver.ai/find.md): locate the element to double-click
* [Perform actions](https://docs.testdriver.ai/performing-actions.md): every kind of action in one guide


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.