mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: GoToAsync -> GotoAsync (#6563)
This commit is contained in:
parent
bdb4aefc8f
commit
6a39b86640
@ -73,7 +73,7 @@ class BrowserExamples
|
||||
var firefox = playwright.Firefox;
|
||||
var browser = await firefox.LaunchAsync(headless: false);
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.GoToAsync("https://www.bing.com");
|
||||
await page.GotoAsync("https://www.bing.com");
|
||||
await browser.CloseAsync();
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ var browser = await playwright.Firefox.LaunchAsync();
|
||||
var context = await browser.NewContextAsync();
|
||||
// Create a new page in a pristine context.
|
||||
var page = await context.NewPageAsync(); ;
|
||||
await page.GoToAsync("https://www.bing.com");
|
||||
await page.GotoAsync("https://www.bing.com");
|
||||
```
|
||||
|
||||
### option: Browser.newContext.-inline- = %%-shared-context-params-list-%%
|
||||
|
||||
@ -56,7 +56,7 @@ var browser = await playwright.Firefox.LaunchAsync(headless: false);
|
||||
var context = await browser.NewContextAsync();
|
||||
// Create a new page inside context.
|
||||
var page = await context.NewPageAsync();
|
||||
await page.GoToAsync("https://bing.com");
|
||||
await page.GotoAsync("https://bing.com");
|
||||
// Dispose context once it"s no longer needed.
|
||||
await context.CloseAsync();
|
||||
```
|
||||
@ -895,7 +895,7 @@ browser.close()
|
||||
var context = await browser.NewContextAsync();
|
||||
var page = await context.NewPageAsync();
|
||||
await context.RouteAsync("**/*.{png,jpg,jpeg}", r => r.AbortAsync());
|
||||
await page.GoToAsync("https://theverge.com");
|
||||
await page.GotoAsync("https://theverge.com");
|
||||
await browser.CloseAsync();
|
||||
```
|
||||
|
||||
@ -940,7 +940,7 @@ browser.close()
|
||||
var context = await browser.NewContextAsync();
|
||||
var page = await context.NewPageAsync();
|
||||
await context.RouteAsync(new Regex("(\\.png$)|(\\.jpg$)"), r => r.AbortAsync());
|
||||
await page.GoToAsync("https://theverge.com");
|
||||
await page.GotoAsync("https://theverge.com");
|
||||
await browser.CloseAsync();
|
||||
```
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class HandleExamples
|
||||
using var playwright = await Playwright.CreateAsync();
|
||||
var browser = await playwright.Chromium.LaunchAsync(headless: false);
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.GoToAsync("https://www.bing.com");
|
||||
await page.GotoAsync("https://www.bing.com");
|
||||
var handle = await page.QuerySelectorAsync("a");
|
||||
await handle.ClickAsync();
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ class FrameExamples
|
||||
await using var browser = await playwright.Firefox.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
|
||||
await page.GoToAsync("https://www.bing.com");
|
||||
await page.GotoAsync("https://www.bing.com");
|
||||
DumpFrameTree(page.MainFrame, string.Empty);
|
||||
}
|
||||
|
||||
@ -1540,7 +1540,7 @@ class FrameExamples
|
||||
|
||||
foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
|
||||
{
|
||||
await page.GoToAsync(currentUrl);
|
||||
await page.GotoAsync(currentUrl);
|
||||
element = await page.MainFrame.WaitForSelectorAsync("img");
|
||||
Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ browser.close()
|
||||
```
|
||||
|
||||
```csharp
|
||||
await page.GoToAsync("https://keycode.info");
|
||||
await page.GotoAsync("https://keycode.info");
|
||||
await page.Keyboard.PressAsync("A");
|
||||
await page.ScreenshotAsync("A.png");
|
||||
await page.Keyboard.PressAsync("ArrowLeft");
|
||||
|
||||
@ -84,7 +84,7 @@ class PageExamples
|
||||
using var playwright = await Playwright.CreateAsync();
|
||||
await using var browser = await playwright.Webkit.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.GoToAsync("https://www.theverge.com");
|
||||
await page.GotoAsync("https://www.theverge.com");
|
||||
await page.ScreenshotAsync("theverge.png");
|
||||
}
|
||||
}
|
||||
@ -2266,7 +2266,7 @@ browser.close()
|
||||
```csharp
|
||||
await using var browser = await playwright.Webkit.LaunchAsync(headless: false);
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.GoToAsync("https://keycode.info");
|
||||
await page.GotoAsync("https://keycode.info");
|
||||
await page.PressAsync("body", "A");
|
||||
await page.ScreenshotAsync("A.png");
|
||||
await page.PressAsync("body", "ArrowLeft");
|
||||
@ -2371,7 +2371,7 @@ browser.close()
|
||||
await using var browser = await playwright.Webkit.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.RouteAsync("**/*.{png,jpg,jpeg}", async r => await r.AbortAsync());
|
||||
await page.GoToAsync("https://www.microsoft.com");
|
||||
await page.GotoAsync("https://www.microsoft.com");
|
||||
```
|
||||
|
||||
or the same snippet using a regex pattern instead:
|
||||
@ -2408,7 +2408,7 @@ browser.close()
|
||||
await using var browser = await playwright.Webkit.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.RouteAsync(new Regex("(\\.png$)|(\\.jpg$)"), async r => await r.AbortAsync());
|
||||
await page.GoToAsync("https://www.microsoft.com");
|
||||
await page.GotoAsync("https://www.microsoft.com");
|
||||
```
|
||||
|
||||
It is possible to examine the request to decide the route action. For example, mocking all requests that contain some post data, and leaving all other requests as is:
|
||||
@ -2708,7 +2708,7 @@ page.goto("https://example.com")
|
||||
```csharp
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.SetViewportSizeAsync(640, 480);
|
||||
await page.GoToAsync("https://www.microsoft.com");
|
||||
await page.GotoAsync("https://www.microsoft.com");
|
||||
```
|
||||
|
||||
### param: Page.setViewportSize.viewportSize
|
||||
@ -3565,7 +3565,7 @@ class FrameExamples
|
||||
|
||||
foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
|
||||
{
|
||||
await page.GoToAsync(currentUrl);
|
||||
await page.GotoAsync(currentUrl);
|
||||
var element = await page.WaitForSelectorAsync("img");
|
||||
Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class PlaywrightExample
|
||||
await using var browser = await playwright.Chromium.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
|
||||
await page.GoToAsync("https://www.microsoft.com");
|
||||
await page.GotoAsync("https://www.microsoft.com");
|
||||
// other actions...
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ class PlaywrightExample
|
||||
await using var context = await browser.NewContextAsync(Playwright.Devices["iPhone 6"]);
|
||||
|
||||
var page = await context.NewPageAsync();
|
||||
await page.GoToAsync("https://www.theverge.com");
|
||||
await page.GotoAsync("https://www.theverge.com");
|
||||
// other actions...
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ print(response.request.redirected_from.url) # "http://example.com"
|
||||
```
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
@ -144,7 +144,7 @@ print(response.request.redirected_from) # None
|
||||
```
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
@ -240,7 +240,7 @@ print(request.timing)
|
||||
|
||||
```csharp
|
||||
var requestFinishedTask = page.WaitForEventAsync(PageEvent.RequestFinished);
|
||||
await Task.WhenAll(requestFinishedTask, page.GoToAsync("https://www.microsoft.com"));
|
||||
await Task.WhenAll(requestFinishedTask, page.GotoAsync("https://www.microsoft.com"));
|
||||
Console.WriteLine(requestFinishedTask.Result.Timing.ResponseEnd);
|
||||
```
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ dotnet add package PlaywrightSharp
|
||||
using var playwright = await Playwright.CreateAsync();
|
||||
await using var browser = await playwright.Chromium.LaunchAsync();
|
||||
var page = await browser.NewPageAsync();
|
||||
await page.GoToAsync("http://www.bing.com");
|
||||
await page.GotoAsync("http://www.bing.com");
|
||||
await page.ScreenshotAsync(path: outputFile);
|
||||
```
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ export class CSharpLanguageGenerator implements LanguageGenerator {
|
||||
if (action.name === 'openPage') {
|
||||
formatter.add(`var ${pageAlias} = await context.NewPageAsync();`);
|
||||
if (action.url && action.url !== 'about:blank' && action.url !== 'chrome://newtab/')
|
||||
formatter.add(`await ${pageAlias}.GoToAsync(${quote(action.url)});`);
|
||||
formatter.add(`await ${pageAlias}.GotoAsync(${quote(action.url)});`);
|
||||
return formatter.format();
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ export class CSharpLanguageGenerator implements LanguageGenerator {
|
||||
return `PressAsync(${quote(action.selector)}, ${quote(shortcut)})`;
|
||||
}
|
||||
case 'navigate':
|
||||
return `GoToAsync(${quote(action.url)})`;
|
||||
return `GotoAsync(${quote(action.url)})`;
|
||||
case 'select':
|
||||
return `SelectOptionAsync(${quote(action.selector)}, ${formatObject(action.options.length > 1 ? action.options : action.options[0])})`;
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ await page.ClickAsync(\"text=click me\");`);
|
||||
expect(sources.get('<csharp>').text).toContain(`
|
||||
// Open new page
|
||||
var page1 = await context.NewPageAsync();
|
||||
await page1.GoToAsync("about:blank?foo");`);
|
||||
await page1.GotoAsync("about:blank?foo");`);
|
||||
} else if (browserName === 'firefox') {
|
||||
expect(sources.get('<javascript>').text).toContain(`
|
||||
// Click text=link
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user