microsoft / microsoft/playwright

[Feature]: Automatic waiting to resolve strict mode violations

Open
#36,045 6 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

### 🚀 Feature Request

When there is a strict mode violation, instead of immediately raising an exception, wait the usual time for the strict mode violation to resolve

### Example

In a test scenario, where an open dialog should be closed by clicking the close button:

```ts
await page.getByLabel('close').click();
```

If there are still some auto-disappearing toast messages visible on the page, and they have a dismiss-button with the same label, the test will immediately crash.

Current workaround:

```ts
await expect(page.getByLabel('close')).toHaveCount(1);
await page.getByLabel('close').click();
```

Suggested change:

Instead, each action that would raise a strict-mode-violation should first perform an expect wait like from the workaround, and only actually fail when the violation is still present after the timeout.

### Motivation

It would make workarounds like above unnecessary, and also align the code generated from the recording feature more aligned with the actual working test code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file or test is named. Start by tracing the strict-mode-violation handling and the expect wait behavior shown in the workaround; done means actions wait through the usual timeout and fail only if multiple matches remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.