docs(dotnet): add note about using assertions with library (#23642)

Common question.
This commit is contained in:
Max Schmitt 2023-06-13 18:04:13 +02:00 committed by GitHub
parent 460e7fcfa2
commit e5b07d662c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,21 @@ await using var browser = await playwright.Firefox.LaunchAsync(new()
});
```
## Using Assertions
You can do the following to leverage Playwright's web-first assertions when you are using your own test framework. These will automatically retry until the condition is met, e.g. an element has a certain text or the timeout is reached:
```csharp
using Microsoft.Playwright;
using static Microsoft.Playwright.Assertions;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await Expect(page.GetByRole(AriaRole.Link, new() { Name = "Get started" })).ToBeVisibleAsync();
```
## Bundle drivers for different platforms
Playwright by default does bundle only the driver for the .NET publish target runtime. If you want to bundle for additional platforms, you can