mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
docs(core-concepts): mention newPage in browser context section (#8984)
This commit is contained in:
parent
d13b7703a7
commit
b5f6952f23
@ -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/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user