mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 14:11:50 +03:00
docs(dotnet): Browser examples (#6490)
This commit is contained in:
parent
00ec43974d
commit
3f6461189b
@ -61,6 +61,24 @@ with sync_playwright() as playwright:
|
|||||||
run(playwright)
|
run(playwright)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using Microsoft.Playwright;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
class BrowserExamples
|
||||||
|
{
|
||||||
|
public static async Task Main()
|
||||||
|
{
|
||||||
|
using var playwright = await Playwright.CreateAsync();
|
||||||
|
var firefox = playwright.Firefox;
|
||||||
|
var browser = await firefox.LaunchAsync(headless: false);
|
||||||
|
var page = await browser.NewPageAsync();
|
||||||
|
await page.GoToAsync("https://www.bing.com");
|
||||||
|
await browser.CloseAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## event: Browser.disconnected
|
## event: Browser.disconnected
|
||||||
- argument: <[Browser]>
|
- argument: <[Browser]>
|
||||||
|
|
||||||
@ -112,6 +130,14 @@ context = browser.new_context()
|
|||||||
print(len(browser.contexts())) # prints `1`
|
print(len(browser.contexts())) # prints `1`
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using var playwright = await Playwright.CreateAsync();
|
||||||
|
var browser = await playwright.Webkit.LaunchAsync();
|
||||||
|
System.Console.WriteLine(browser.Contexts.Count); // prints "0"
|
||||||
|
var context = await browser.NewContextAsync();
|
||||||
|
System.Console.WriteLine(browser.Contexts.Count); // prints "1"
|
||||||
|
```
|
||||||
|
|
||||||
## method: Browser.isConnected
|
## method: Browser.isConnected
|
||||||
- returns: <[boolean]>
|
- returns: <[boolean]>
|
||||||
|
|
||||||
@ -170,6 +196,16 @@ page = context.new_page()
|
|||||||
page.goto("https://example.com")
|
page.goto("https://example.com")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using var playwright = await Playwright.CreateAsync();
|
||||||
|
var browser = await playwright.Firefox.LaunchAsync();
|
||||||
|
// Create a new incognito browser context.
|
||||||
|
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");
|
||||||
|
```
|
||||||
|
|
||||||
### option: Browser.newContext.-inline- = %%-shared-context-params-list-%%
|
### option: Browser.newContext.-inline- = %%-shared-context-params-list-%%
|
||||||
|
|
||||||
### option: Browser.newContext.proxy = %%-context-option-proxy-%%
|
### option: Browser.newContext.proxy = %%-context-option-proxy-%%
|
||||||
|
Loading…
Reference in New Issue
Block a user