mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs(dotnet): Playwright examples (#6558)
This commit is contained in:
parent
47645ec815
commit
ea59fd8f83
@ -65,6 +65,24 @@ with sync_playwright() as playwright:
|
|||||||
run(playwright)
|
run(playwright)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using Microsoft.Playwright;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
class PlaywrightExample
|
||||||
|
{
|
||||||
|
public static async Task Main()
|
||||||
|
{
|
||||||
|
using var playwright = await Playwright.CreateAsync();
|
||||||
|
await using var browser = await playwright.Chromium.LaunchAsync();
|
||||||
|
var page = await browser.NewPageAsync();
|
||||||
|
|
||||||
|
await page.GoToAsync("https://www.microsoft.com");
|
||||||
|
// other actions...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## property: Playwright.chromium
|
## property: Playwright.chromium
|
||||||
- type: <[BrowserType]>
|
- type: <[BrowserType]>
|
||||||
|
|
||||||
@ -135,6 +153,25 @@ with sync_playwright() as playwright:
|
|||||||
|
|
||||||
Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
|
Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using Microsoft.Playwright;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
class PlaywrightExample
|
||||||
|
{
|
||||||
|
public static async Task Main()
|
||||||
|
{
|
||||||
|
using var playwright = await Playwright.CreateAsync();
|
||||||
|
await using var browser = await playwright.Webkit.LaunchAsync();
|
||||||
|
await using var context = await browser.NewContextAsync(Playwright.Devices["iPhone 6"]);
|
||||||
|
|
||||||
|
var page = await context.NewPageAsync();
|
||||||
|
await page.GoToAsync("https://www.theverge.com");
|
||||||
|
// other actions...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## property: Playwright.errors
|
## property: Playwright.errors
|
||||||
* langs: js
|
* langs: js
|
||||||
- type: <[Object]>
|
- type: <[Object]>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user