Skip to content

Commit

Permalink
docs: make docs a bit shorter, so it's more consumable
Browse files Browse the repository at this point in the history
  • Loading branch information
rannes committed Oct 30, 2024
1 parent 43abe5f commit adff3a1
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions doc/AG0044.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,52 +101,6 @@ public async Task InteractWithSlowElementAsync(ILocator element)
- Can become flaky or inconsistent
- Are harder to debug when they fail

## How to Fix It
1. **Use Proper Wait Strategies**:
```csharp
// Instead of Force = true
await element.WaitForAsync(new()
{
State = WaitForSelectorState.Visible,
Timeout = 5000
});
await element.ClickAsync();
```

2. **Adjust Timeouts When Needed**:
```csharp
await element.ClickAsync(new() { Timeout = 10000 });
```

3. **Use State Assertions**:
```csharp
await element.WaitForAsync(new() { State = WaitForSelectorState.Enabled });
await Assertions.Expect(element).ToBeVisibleAsync();
await element.ClickAsync();
```

4. **Handle Dynamic Content**:
```csharp
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await element.WaitForAsync();
await element.ClickAsync();
```

## Benefits
- More reliable and stable tests
- Better representation of real user interactions
- Easier debugging when tests fail
- Catches actual UI/UX issues
- More maintainable test code

## Exceptions
Force option might be acceptable in very specific scenarios:
- Testing error cases where elements are intentionally obscured
- Dealing with known browser-specific edge cases
- Temporary workarounds while investigating underlying issues

However, these should be rare exceptions and well-documented.

## References
- [Playwright Actionability](https://playwright.dev/dotnet/docs/actionability)
- [Playwright Forcing Actions](https://playwright.dev/dotnet/docs/actionability#forcing-actions)

0 comments on commit adff3a1

Please sign in to comment.