Max Schmitt 2023-11-07 09:28:18 +01:00 committed by GitHub
parent 810382c074
commit 19b0f5ccb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 22 deletions

View file

@ -85,7 +85,7 @@ assertThat(page).not().hasURL("error");
``` ```
```csharp ```csharp
await Expect(page).Not.ToHaveURL("error"); await Expect(Page).Not.ToHaveURL("error");
``` ```
## async method: PageAssertions.NotToHaveTitle ## async method: PageAssertions.NotToHaveTitle
@ -261,7 +261,7 @@ expect(page).to_have_title(re.compile(r".*checkout"))
``` ```
```csharp ```csharp
await Expect(page).ToHaveTitle("Playwright"); await Expect(Page).ToHaveTitle("Playwright");
``` ```
### param: PageAssertions.toHaveTitle.titleOrRegExp ### param: PageAssertions.toHaveTitle.titleOrRegExp
@ -310,7 +310,7 @@ expect(page).to_have_url(re.compile(".*checkout"))
``` ```
```csharp ```csharp
await Expect(page).ToHaveURL(new Regex(".*checkout")); await Expect(Page).ToHaveURL(new Regex(".*checkout"));
``` ```
### param: PageAssertions.toHaveURL.urlOrRegExp ### param: PageAssertions.toHaveURL.urlOrRegExp

View file

@ -157,7 +157,7 @@ PlaywrightAssertions.assertThat(page).hasTitle("News");
``` ```
```csharp ```csharp
await Expect(page).ToHaveTitleAsync("News"); await Expect(Page).ToHaveTitleAsync("News");
``` ```
### param: PlaywrightAssertions.expectPage.page ### param: PlaywrightAssertions.expectPage.page

View file

@ -1589,7 +1589,7 @@ page.getByRole(AriaRole.BUTTON,
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByRole(AriaRole.Heading, new() { Name = "Sign up" })) .GetByRole(AriaRole.Heading, new() { Name = "Sign up" }))
.ToBeVisibleAsync(); .ToBeVisibleAsync();
@ -1641,7 +1641,7 @@ expect(page.get_by_title("Issues count")).to_have_text("25 issues")
``` ```
```csharp ```csharp
await Expect(page.GetByTitle("Issues count")).toHaveText("25 issues"); await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
``` ```
## test-config-snapshot-path-template ## test-config-snapshot-path-template

View file

@ -68,7 +68,7 @@ await page.GetByLabel("Password").FillAsync("secret-password");
await page.GetByRole(AriaRole.Button, new() { Name = "Sign in" }).ClickAsync(); await page.GetByRole(AriaRole.Button, new() { Name = "Sign in" }).ClickAsync();
await Expect(page.GetByText("Welcome, John!")).ToBeVisibleAsync(); await Expect(Page.GetByText("Welcome, John!")).ToBeVisibleAsync();
``` ```
## Locating elements ## Locating elements
@ -245,7 +245,7 @@ page.getByRole(AriaRole.BUTTON,
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByRole(AriaRole.Heading, new() { Name = "Sign up" })) .GetByRole(AriaRole.Heading, new() { Name = "Sign up" }))
.ToBeVisibleAsync(); .ToBeVisibleAsync();
@ -373,7 +373,7 @@ expect(page.get_by_text("Welcome, John")).to_be_visible()
``` ```
```csharp ```csharp
await Expect(page.GetByText("Welcome, John")).ToBeVisibleAsync(); await Expect(Page.GetByText("Welcome, John")).ToBeVisibleAsync();
``` ```
Set an exact match: Set an exact match:
@ -396,7 +396,7 @@ expect(page.get_by_text("Welcome, John", exact=True)).to_be_visible()
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByText("Welcome, John", new() { Exact = true })) .GetByText("Welcome, John", new() { Exact = true }))
.ToBeVisibleAsync(); .ToBeVisibleAsync();
``` ```
@ -424,7 +424,7 @@ expect(page.get_by_text(re.compile("welcome, john", re.IGNORECASE))).to_be_visib
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByText(new Regex("welcome, john", RegexOptions.IgnoreCase))) .GetByText(new Regex("welcome, john", RegexOptions.IgnoreCase)))
.ToBeVisibleAsync(); .ToBeVisibleAsync();
``` ```
@ -504,7 +504,7 @@ expect(page.get_by_title("Issues count")).to_have_text("25 issues")
``` ```
```csharp ```csharp
await Expect(page.GetByTitle("Issues count")).toHaveText("25 issues"); await Expect(Page.GetByTitle("Issues count")).toHaveText("25 issues");
``` ```
:::note When to use title locators :::note When to use title locators
@ -784,7 +784,7 @@ await expect(page.locator("x-details")).to_contain_text("Details")
expect(page.locator("x-details")).to_contain_text("Details") expect(page.locator("x-details")).to_contain_text("Details")
``` ```
```csharp ```csharp
await Expect(page.Locator("x-details")).ToContainTextAsync("Details"); await Expect(Page.Locator("x-details")).ToContainTextAsync("Details");
``` ```
## Filtering Locators ## Filtering Locators
@ -910,7 +910,7 @@ expect(page.get_by_role("listitem").filter(has_not_text="Out of stock")).to_have
```csharp ```csharp
// 5 in-stock items // 5 in-stock items
await Expect(page.getByRole(AriaRole.Listitem).Filter(new() { HasNotText = "Out of stock" })) await Expect(Page.getByRole(AriaRole.Listitem).Filter(new() { HasNotText = "Out of stock" }))
.ToHaveCountAsync(5); .ToHaveCountAsync(5);
``` ```
@ -1006,7 +1006,7 @@ expect(
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByRole(AriaRole.Listitem) .GetByRole(AriaRole.Listitem)
.Filter(new() { .Filter(new() {
Has = page.GetByRole(AriaRole.Heading, new() { Name = "Product 2" }) Has = page.GetByRole(AriaRole.Heading, new() { Name = "Product 2" })
@ -1049,7 +1049,7 @@ expect(
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByRole(AriaRole.Listitem) .GetByRole(AriaRole.Listitem)
.Filter(new() { .Filter(new() {
HasNot = page.GetByRole(AriaRole.Heading, new() { Name = "Product 2" }) HasNot = page.GetByRole(AriaRole.Heading, new() { Name = "Product 2" })
@ -1309,7 +1309,7 @@ assertThat(page.getByRole(AriaRole.LISTITEM).hasCount(3);
``` ```
```csharp ```csharp
await Expect(page.GetByRole(AriaRole.Listitem)).ToHaveCountAsync(3); await Expect(Page.GetByRole(AriaRole.Listitem)).ToHaveCountAsync(3);
``` ```
### Assert all text in a list ### Assert all text in a list
@ -1349,7 +1349,7 @@ assertThat(page
``` ```
```csharp ```csharp
await Expect(page await Expect(Page
.GetByRole(AriaRole.Listitem)) .GetByRole(AriaRole.Listitem))
.ToHaveTextAsync(new string[] {"apple", "banana", "orange"}); .ToHaveTextAsync(new string[] {"apple", "banana", "orange"});
``` ```

View file

@ -726,7 +726,7 @@ expect(page.locator("label")).to_have_text("Password")
```csharp ```csharp
// Fill the input by targeting the label. // Fill the input by targeting the label.
await Expect(page.Locator("label")).ToHaveTextAsync("Password"); await Expect(Page.Locator("label")).ToHaveTextAsync("Password");
``` ```
## Legacy text locator ## Legacy text locator

View file

@ -373,7 +373,7 @@ await page.GetByLabel("Password").FillAsync("secret-password");
await page.GetByRole(AriaRole.Button, new() { NameString = "Sign in" }).ClickAsync(); await page.GetByRole(AriaRole.Button, new() { NameString = "Sign in" }).ClickAsync();
await Expect(page.GetByText("Welcome, John!")).ToBeVisibleAsync(); await Expect(Page.GetByText("Welcome, John!")).ToBeVisibleAsync();
``` ```
All the same methods are also available on [Locator], [FrameLocator] and [Frame] classes. All the same methods are also available on [Locator], [FrameLocator] and [Frame] classes.
@ -387,7 +387,7 @@ All the same methods are also available on [Locator], [FrameLocator] and [Frame]
- [`method: LocatorAssertions.toHaveAttribute`] with an empty value does not match missing attribute anymore. For example, the following snippet will succeed when `button` **does not** have a `disabled` attribute. - [`method: LocatorAssertions.toHaveAttribute`] with an empty value does not match missing attribute anymore. For example, the following snippet will succeed when `button` **does not** have a `disabled` attribute.
```csharp ```csharp
await Expect(page.GetByRole(AriaRole.Button)).ToHaveAttribute("disabled", ""); await Expect(Page.GetByRole(AriaRole.Button)).ToHaveAttribute("disabled", "");
``` ```
### Browser Versions ### Browser Versions

View file

@ -50,7 +50,7 @@ public class Tests : PageTest
await getStarted.ClickAsync(); await getStarted.ClickAsync();
// Expects page to have a heading with the name of Installation. // Expects page to have a heading with the name of Installation.
await Expect(page await Expect(Page
.GetByRole(AriaRole.Heading, new() { Name = "Installation" })) .GetByRole(AriaRole.Heading, new() { Name = "Installation" }))
.ToBeVisibleAsync(); .ToBeVisibleAsync();
} }