docs(dotnet): fix code snippets for GoToAsync

This commit is contained in:
amaechi hope 2024-10-31 15:21:34 +01:00
parent a8ee6d0017
commit 2a5f9a2e7b
9 changed files with 20 additions and 20 deletions

View file

@ -290,7 +290,7 @@ browser.close()
``` ```
```csharp ```csharp
await page.GotoAsync("https://keycode.info"); await Page.GotoAsync("https://keycode.info");
await page.Keyboard.PressAsync("A"); await page.Keyboard.PressAsync("A");
await page.ScreenshotAsync(new() { Path = "A.png" }); await page.ScreenshotAsync(new() { Path = "A.png" });
await page.Keyboard.PressAsync("ArrowLeft"); await page.Keyboard.PressAsync("ArrowLeft");

View file

@ -2138,7 +2138,7 @@ expect(page.locator('body')).to_match_aria_snapshot('''
``` ```
```csharp ```csharp
await page.GotoAsync("https://demo.playwright.dev/todomvc/"); await Page.GotoAsync("https://demo.playwright.dev/todomvc/");
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@" await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- heading ""todos"" - heading ""todos""
- textbox ""What needs to be done?"" - textbox ""What needs to be done?""

View file

@ -3191,7 +3191,7 @@ await page.AddLocatorHandlerAsync(Page.GetByText("Sign up to the newsletter"), a
}); });
// Write the test as usual. // Write the test as usual.
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync(); await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync();
``` ```
@ -3248,7 +3248,7 @@ await page.AddLocatorHandlerAsync(Page.GetByText("Confirm your security details"
}); });
// Write the test as usual. // Write the test as usual.
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync(); await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync();
``` ```
@ -3305,7 +3305,7 @@ await page.AddLocatorHandlerAsync(page.Locator("body"), async () => {
}, new() { NoWaitAfter = true }); }, new() { NoWaitAfter = true });
// Write the test as usual. // Write the test as usual.
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync(); await page.GetByRole("button", new() { Name = "Start here" }).ClickAsync();
``` ```

View file

@ -214,7 +214,7 @@ print(response.request.redirected_from.url) # "http://example.com"
``` ```
```csharp ```csharp
var response = await page.GotoAsync("http://www.microsoft.com"); var response = await Page.GotoAsync("http://www.microsoft.com");
Console.WriteLine(response.Request.RedirectedFrom?.Url); // http://www.microsoft.com Console.WriteLine(response.Request.RedirectedFrom?.Url); // http://www.microsoft.com
``` ```
@ -241,7 +241,7 @@ print(response.request.redirected_from) # None
``` ```
```csharp ```csharp
var response = await page.GotoAsync("https://www.google.com"); var response = await Page.GotoAsync("https://www.google.com");
Console.WriteLine(response.Request.RedirectedFrom?.Url); // null Console.WriteLine(response.Request.RedirectedFrom?.Url); // null
``` ```
@ -368,7 +368,7 @@ print(request.timing)
```csharp ```csharp
var request = await page.RunAndWaitForRequestFinishedAsync(async () => var request = await page.RunAndWaitForRequestFinishedAsync(async () =>
{ {
await page.GotoAsync("https://www.microsoft.com"); await Page.GotoAsync("https://www.microsoft.com");
}); });
Console.WriteLine(request.Timing.ResponseEnd); Console.WriteLine(request.Timing.ResponseEnd);
``` ```

View file

@ -266,7 +266,7 @@ assertThat(page.getByText("You have been logged out due to inactivity.")).isVisi
```csharp ```csharp
// Initial time does not matter for the test, so we can pick current time. // Initial time does not matter for the test, so we can pick current time.
await Page.Clock.InstallAsync(); await Page.Clock.InstallAsync();
await page.GotoAsync("http://localhost:3333"); await Page.GotoAsync("http://localhost:3333");
// Interact with the page // Interact with the page
await page.GetByRole("button").ClickAsync(); await page.GetByRole("button").ClickAsync();
@ -375,7 +375,7 @@ await Page.Clock.InstallAsync(new()
{ {
TimeDate = new DateTime(2024, 2, 2, 8, 0, 0, DateTimeKind.Pst) TimeDate = new DateTime(2024, 2, 2, 8, 0, 0, DateTimeKind.Pst)
}); });
await page.GotoAsync("http://localhost:3333"); await Page.GotoAsync("http://localhost:3333");
var locator = page.GetByTestId("current-time"); var locator = page.GetByTestId("current-time");
// Pause the time flow, stop the timers, you now have manual control // Pause the time flow, stop the timers, you now have manual control

View file

@ -45,7 +45,7 @@ print(first.value.url)
```csharp ```csharp
var waitForRequestTask = page.WaitForRequestAsync("**/*logo*.png"); var waitForRequestTask = page.WaitForRequestAsync("**/*logo*.png");
await page.GotoAsync("https://wikipedia.org"); await Page.GotoAsync("https://wikipedia.org");
var request = await waitForRequestTask; var request = await waitForRequestTask;
Console.WriteLine(request.Url); Console.WriteLine(request.Url);
``` ```
@ -152,11 +152,11 @@ void listener(object sender, IRequest request)
Console.WriteLine("Request finished: " + request.Url); Console.WriteLine("Request finished: " + request.Url);
}; };
page.RequestFinished += listener; page.RequestFinished += listener;
await page.GotoAsync("https://wikipedia.org"); await Page.GotoAsync("https://wikipedia.org");
// Remove previously added listener. // Remove previously added listener.
page.RequestFinished -= listener; page.RequestFinished -= listener;
await page.GotoAsync("https://www.openstreetmap.org/"); await Page.GotoAsync("https://www.openstreetmap.org/");
``` ```
## Adding one-off listeners ## Adding one-off listeners

View file

@ -73,7 +73,7 @@ await page.RouteAsync("*/**/api/v1/fruits", async route => {
}); });
// Go to the page // Go to the page
await page.GotoAsync("https://demo.playwright.dev/api-mocking"); await Page.GotoAsync("https://demo.playwright.dev/api-mocking");
// Assert that the Strawberry fruit is visible // Assert that the Strawberry fruit is visible
await Expect(Page.GetByTextAsync("Strawberry")).ToBeVisibleAsync(); await Expect(Page.GetByTextAsync("Strawberry")).ToBeVisibleAsync();
@ -185,7 +185,7 @@ await page.RouteAsync("*/**/api/v1/fruits", async (route) => {
} }
); );
// Go to the page // Go to the page
await page.GotoAsync("https://demo.playwright.dev/api-mocking"); await Page.GotoAsync("https://demo.playwright.dev/api-mocking");
// Assert that the Loquat fruit is visible // Assert that the Loquat fruit is visible
await Expect(Page.GetByTextAsync("Loquat", new () { Exact = true })).ToBeVisibleAsync(); await Expect(Page.GetByTextAsync("Loquat", new () { Exact = true })).ToBeVisibleAsync();
@ -280,7 +280,7 @@ await page.RouteFromHARAsync("./hars/fruit.har", new () {
}); });
// Go to the page // Go to the page
await page.GotoAsync("https://demo.playwright.dev/api-mocking"); await Page.GotoAsync("https://demo.playwright.dev/api-mocking");
// Assert that the fruit is visible // Assert that the fruit is visible
await Expect(Page.GetByText("Strawberry")).ToBeVisibleAsync(); await Expect(Page.GetByText("Strawberry")).ToBeVisibleAsync();
@ -376,7 +376,7 @@ await page.RouteFromHARAsync("./hars/fruit.har", new ()
); );
// Go to the page // Go to the page
await page.GotoAsync("https://demo.playwright.dev/api-mocking"); await Page.GotoAsync("https://demo.playwright.dev/api-mocking");
// Assert that the Playwright fruit is visible // Assert that the Playwright fruit is visible
await page.ExpectByTextAsync("Playwright", new() { Exact = true }).ToBeVisibleAsync(); await page.ExpectByTextAsync("Playwright", new() { Exact = true }).ToBeVisibleAsync();

View file

@ -33,7 +33,7 @@ page.goto("https://example.com")
```csharp ```csharp
// Navigate the page // Navigate the page
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
``` ```
The code above loads the page and waits for the web page to fire the The code above loads the page and waits for the web page to fire the
@ -88,7 +88,7 @@ page.get_by_text("example domain").click()
```csharp ```csharp
// Navigate and click element // Navigate and click element
// Click will auto-wait for the element // Click will auto-wait for the element
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
await Page.GetByText("Example Domain").ClickAsync(); await Page.GetByText("Example Domain").ClickAsync();
``` ```

View file

@ -476,7 +476,7 @@ page.goto("https://example.com")
await page.RouteAsync("**/api/fetch_data", async route => { await page.RouteAsync("**/api/fetch_data", async route => {
await route.FulfillAsync(new() { Status = 200, Body = testData }); await route.FulfillAsync(new() { Status = 200, Body = testData });
}); });
await page.GotoAsync("https://example.com"); await Page.GotoAsync("https://example.com");
``` ```
## Modify requests ## Modify requests