Skip to content
Back to skills

Testdriver Waiting For Elements

ASecurity

Handle async operations and prevent flaky tests

  • 243 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 6, 2026
ai-agentsjavascriptjava

Works with

  • cli

Security analysis

A100/100

Scanned September 6, 2026

npx -y skills add testdriverai/testdriverai --skill testdriver-waiting-for-elements --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testdriver Waiting For Elements?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testdriver Waiting For Elements
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/testdriverai-testdriver-waiting-for-elements/badge)](https://www.skillsdirectory.com/skills/testdriverai-testdriver-waiting-for-elements)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: testdriver:waiting-for-elements
description: Handle async operations and prevent flaky tests
---
<!-- Generated from waiting-for-elements.mdx. DO NOT EDIT. -->

## Waiting for Elements

By default, `find()` automatically polls for up to 10 seconds, retrying every 5 seconds until the element is found. This means most elements that appear after short async operations will be found without any extra configuration.

For longer operations, increase the `timeout`:

```javascript
// Default behavior - polls for up to 10 seconds automatically
const element = await testdriver.find('Loading complete indicator');
await element.click();

// Wait up to 30 seconds for slower operations
const element = await testdriver.find('Loading complete indicator', { timeout: 30000 });
await element.click();

// Useful after actions that trigger loading states
await testdriver.find('submit button').click();
await testdriver.find('success message', { timeout: 15000 });

// Disable polling for instant checks
const toast = await testdriver.find('notification toast', { timeout: 0 });
```

## Flake Prevention

TestDriver automatically waits for the screen and network to stabilize after each action using **redraw detection**. This prevents flaky tests caused by animations, loading states, or dynamic content updates.

<Note>
  Redraw detection adds a small delay after each action but significantly reduces test flakiness.
</Note>

For example, when clicking a submit button that navigates to a new page:

```javascript
// Click submit - TestDriver automatically waits for the new page to load
await testdriver.find('submit button').click();

// By the time this runs, the page has fully loaded and stabilized
await testdriver.assert('dashboard is displayed');
await testdriver.find('welcome message');
```

Without redraw detection, you'd need manual waits or retries to handle the page transition. TestDriver handles this automatically by detecting when the screen stops changing and network requests complete.

You can disable redraw detection or customize its behavior:

```javascript
// Disable redraw detection for faster tests (less reliable)
const testdriver = TestDriver(context, { 
  redraw: false 
});
```

Here is an example of customizing redraw detection:

```javascript
// Fine-tune redraw detection
const testdriver = TestDriver(context, { 
  redraw: {
    enabled: true,
    diffThreshold: 0.1,      // Pixel difference threshold (0-1)
    screenRedraw: true,      // Monitor screen changes
    networkMonitor: true,    // Wait for network idle
  }
});
```

## Simple Delays with `wait()`

For simple pauses — waiting for animations, transitions, or state changes after an action — use `wait()`:

```javascript
// Wait for an animation to complete
await testdriver.find('menu toggle').click();
await testdriver.wait(2000);

// Wait for a page transition to settle
await testdriver.find('next page button').click();
await testdriver.wait(1000);
```

<Note>
  For waiting for specific **elements** to appear, prefer `find()` with a `timeout` option. Use `wait()` only for simple time-based pauses.
</Note>

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.