docs: remove redundant duplicate headed paragraph (#31298)

This commit is contained in:
Max Schmitt 2024-06-14 01:20:14 +02:00 committed by GitHub
parent 132ceff702
commit 4fff548fc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 54 deletions

View File

@ -628,65 +628,15 @@ DEBUG=pw:browser dotnet test
## Running headed
By default, Playwright launches browsers in headless mode. This can be changed by passing a flag when the browser is launched.
```js
// Works across chromium, firefox and webkit
const { chromium } = require('playwright');
const browser = await chromium.launch({ headless: false });
```
```java
// Works across chromium, firefox and webkit
import com.microsoft.playwright.*;
public class Example {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
BrowserType chromium = playwright.chromium();
Browser browser = chromium.launch(new BrowserType.LaunchOptions().setHeadless(false));
}
}
}
```
```python async
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
# Works across chromium, firefox and webkit
browser = await p.chromium.launch(headless=False)
asyncio.run(main())
```
```python sync
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
# Works across chromium, firefox and webkit
browser = p.chromium.launch(headless=False)
```
```csharp
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await playwright.Chromium.LaunchAsync(new()
{
Headless = false
});
```
By default, Playwright launches browsers in headless mode. See in our [Running tests](./running-tests.md#run-tests-in-headed-mode) guide how to run tests in headed mode.
On Linux agents, headed execution requires [Xvfb](https://en.wikipedia.org/wiki/Xvfb) to be installed. Our [Docker image](./docker.md) and GitHub Action have Xvfb pre-installed. To run browsers in headed mode with Xvfb, add `xvfb-run` before the actual command.
```bash js
xvfb-run node index.js
xvfb-run npx playwrght test
```
```bash python
xvfb-run python test.py
xvfb-run pytest
```
```bash java
xvfb-run mvn test

View File

@ -22,7 +22,7 @@ Use the following command to run all tests.
dotnet test
```
### Run your tests in headed mode
### Run tests in headed mode
Use the following command to run your tests in headed mode opening a browser window for each test.

View File

@ -85,6 +85,10 @@ See [here](./test-runners.md) for further details on how to run tests in paralle
See experimental [JUnit integration](./junit.md) to automatically initialize Playwright objects and more.
### Run tests in headed mode
If you prefer, you can run your tests in headed mode by using the `launch(new BrowserType.LaunchOptions().setHeadless(false))` option.
## What's Next
- [Debugging tests](./debug.md)