docs(core-concepts): mention newPage in browser context section (#8984)

This commit is contained in:
Max Schmitt 2021-09-17 13:33:55 +02:00 committed by GitHub
parent d13b7703a7
commit b5f6952f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,26 +99,31 @@ the browser state is isolated between the tests.
```js
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
```
```java
Browser browser = chromium.launch();
BrowserContext context = browser.newContext();
Page page = context.newPage();
```
```python async
browser = await playwright.chromium.launch()
context = await browser.new_context()
page = await context.new_page()
```
```python sync
browser = playwright.chromium.launch()
context = browser.new_context()
page = context.new_page()
```
```csharp
await using var browser = playwright.Chromium.LaunchAsync();
var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();
```
Browser contexts can also be used to emulate multi-page scenarios involving
@ -135,6 +140,7 @@ const context = await browser.newContext({
colorScheme: 'dark',
locale: 'de-DE'
});
const page = await context.newPage();
```
```java
@ -155,6 +161,7 @@ public class Example {
.setGeolocation(52.52, 13.39)
.setColorScheme(ColorScheme.DARK)
.setLocale("de-DE"));
Page page = context.newPage();
}
}
}
@ -193,6 +200,7 @@ with sync_playwright() as p:
geolocation={ 'longitude': 12.492507, 'latitude': 41.889938 },
permissions=['geolocation']
)
page = context.new_page()
browser.close()
```
@ -214,8 +222,7 @@ class PlaywrightExample
};
await using var context = await browser.NewContextAsync(options);
// do work
var page = await browser.NewPageAsync();
}
}
```
@ -224,6 +231,7 @@ class PlaywrightExample
- [BrowserContext]
- [`method: Browser.newContext`]
- [`method: BrowserContext.newPage`]
<br/>