Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(roll): roll to ToT Playwright (roll/10-08-24) #1468

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dotnet/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ All of that could be achieved via [APIRequestContext] methods.

The following examples rely on the [`Microsoft.Playwright.MSTest`](./test-runners.mdx) package which creates a Playwright and Page instance for each test.

<!-- TOC -->

## Writing API Test

[APIRequestContext] can send all kinds of HTTP(S) requests over network.
Expand Down
2 changes: 0 additions & 2 deletions dotnet/docs/screenshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ await Page.ScreenshotAsync(new()

[Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out.

<!-- TOC -->

## Full page screenshots

Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely.
Expand Down
2 changes: 0 additions & 2 deletions java/docs/accessibility-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ A few examples of problems this can catch include:

The following examples rely on the [`com.deque.html.axe-core/playwright`](https://mvnrepository.com/artifact/com.deque.html.axe-core/playwright) Maven package which adds support for running the [axe accessibility testing engine](https://www.deque.com/axe/) as part of your Playwright tests.

<!-- TOC -->

## Disclaimer

Automated accessibility tests can detect some common accessibility problems such as missing or invalid properties. But many accessibility problems can only be discovered through manual testing. We recommend using a combination of automated testing, manual accessibility assessments, and inclusive user testing.
Expand Down
2 changes: 0 additions & 2 deletions java/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Sometimes you may want to send requests to the server directly from Java without

All of that could be achieved via [APIRequestContext] methods.

<!-- TOC -->

## Writing API Test

[APIRequestContext] can send all kinds of HTTP(S) requests over network.
Expand Down
2 changes: 1 addition & 1 deletion java/docs/ci-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/java:v1.45.1-jammy
image: mcr.microsoft.com/playwright/java:v1.46.0-jammy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
Expand Down
10 changes: 5 additions & 5 deletions java/docs/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ trigger:

pool:
vmImage: ubuntu-latest
container: mcr.microsoft.com/playwright/java:v1.45.1-jammy
container: mcr.microsoft.com/playwright/java:v1.46.0-jammy

steps:
- task: JavaToolInstaller@0
Expand All @@ -101,7 +101,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In
executors:
pw-jammy-development:
docker:
- image: mcr.microsoft.com/playwright/java:v1.45.1-jammy
- image: mcr.microsoft.com/playwright/java:v1.46.0-jammy
```

Note: When using the docker agent definition, you are specifying the resource class of where playwright runs to the 'medium' tier [here](https://circleci.com/docs/configuration-reference?#docker-execution-environment). The default behavior of Playwright is to set the number of workers to the detected core count (2 in the case of the medium tier). Overriding the number of workers to greater than this number will cause unnecessary timeouts and failures.
Expand All @@ -112,7 +112,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/java:v1.45.1-jammy' } }
agent { docker { image 'mcr.microsoft.com/playwright/java:v1.46.0-jammy' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -129,7 +129,7 @@ pipeline {
Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.mdx)).

```yml
image: mcr.microsoft.com/playwright/java:v1.45.1-jammy
image: mcr.microsoft.com/playwright/java:v1.46.0-jammy
```

### GitLab CI
Expand All @@ -142,7 +142,7 @@ stages:

tests:
stage: test
image: mcr.microsoft.com/playwright/java:v1.45.1-jammy
image: mcr.microsoft.com/playwright/java:v1.46.0-jammy
script:
...
```
Expand Down
14 changes: 7 additions & 7 deletions java/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This Docker image is intended to be used for testing and development purposes on
### Pull the image

```bash
docker pull mcr.microsoft.com/playwright/java:v1.45.1-jammy
docker pull mcr.microsoft.com/playwright/java:v1.46.0-jammy
```

### Run the image
Expand All @@ -33,15 +33,15 @@ By default, the Docker image will use the `root` user to run the browsers. This
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.

```bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.45.1-jammy /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.46.0-jammy /bin/bash
```

#### Crawling and scraping

On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.

```bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.45.1-jammy /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.46.0-jammy /bin/bash
```

[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
Expand Down Expand Up @@ -76,10 +76,10 @@ See [all available image tags].
We currently publish images with the following tags:
- `:next` - tip-of-tree image version based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:next-jammy` - tip-of-tree image version based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.45.1` - Playwright v1.45.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.45.1-noble` - Playwright v1.45.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.45.1-jammy` - Playwright v1.45.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.45.1-focal` - Playwright v1.45.1 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.46.0` - Playwright v1.46.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.46.0-noble` - Playwright v1.46.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.46.0-jammy` - Playwright v1.46.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.46.0-focal` - Playwright v1.46.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).

:::note
It is recommended to always pin your Docker image to a specific version if possible. If the Playwright version in your Docker image does not match the version in your project/tests, Playwright will be unable to locate browser executables.
Expand Down
2 changes: 1 addition & 1 deletion java/docs/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class App {
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.45.1</version>
<version>1.46.0</version>
</dependency>
</dependencies>
<build>
Expand Down
2 changes: 0 additions & 2 deletions java/docs/junit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ With a few lines of code, you can hook up Playwright to your favorite Java test

In [JUnit](https://junit.org/junit5/), you can use Playwright [fixtures](./junit.mdx#fixtures) to automatically initialize [Playwright], [Browser], [BrowserContext] or [Page]. In the example below, all three test methods use the same [Browser]. Each test uses its own [BrowserContext] and [Page].

<!-- TOC -->

```java
package org.example;

Expand Down
2 changes: 0 additions & 2 deletions java/docs/screenshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ page.screenshot(new Page.ScreenshotOptions()

[Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out.

<!-- TOC -->

## Full page screenshots

Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely.
Expand Down
6 changes: 2 additions & 4 deletions java/docs/test-runners.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ With a few lines of code, you can hook up Playwright to your favorite Java test

Playwright and Browser instances can be reused between tests for better performance. We recommend running each test case in a new BrowserContext, this way browser state will be isolated between the tests.

<!-- TOC -->

## JUnit

In [JUnit](https://junit.org/junit5/) you can initialize [Playwright] and [Browser] in [@BeforeAll](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/BeforeAll.html) method and destroy them in [@AfterAll](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/AfterAll.html). In the example below all three test methods use the same [Browser]. Each test uses its own [BrowserContext] and [Page].
Expand Down Expand Up @@ -200,7 +198,7 @@ repositories {
}

dependencies {
implementation 'com.microsoft.playwright:playwright:1.45.1'
implementation 'com.microsoft.playwright:playwright:1.46.0'
}

application {
Expand Down Expand Up @@ -233,7 +231,7 @@ repositories {
}

dependencies {
implementation("com.microsoft.playwright:playwright:1.45.1")
implementation("com.microsoft.playwright:playwright:1.46.0")
}

application {
Expand Down
2 changes: 0 additions & 2 deletions nodejs/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Sometimes you may want to send requests to the server directly from Node.js with

All of that could be achieved via [APIRequestContext] methods.

<!-- TOC3 -->

## Writing API Test

[APIRequestContext] can send all kinds of HTTP(S) requests over network.
Expand Down
2 changes: 0 additions & 2 deletions nodejs/docs/screenshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ await page.screenshot({ path: 'screenshot.png' });

[Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out.

<!-- TOC -->

## Full page screenshots

Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely.
Expand Down
2 changes: 0 additions & 2 deletions python/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ All of that could be achieved via [APIRequestContext] methods.

The following examples rely on the [`pytest-playwright`](./test-runners.mdx) package which add Playwright fixtures to the Pytest test-runner.

<!-- TOC -->

## Writing API Test

[APIRequestContext] can send all kinds of HTTP(S) requests over network.
Expand Down
2 changes: 0 additions & 2 deletions python/docs/screenshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ await page.screenshot(path="screenshot.png")

[Screenshots API](./api/class-page#page-screenshot) accepts many parameters for image format, clip area, quality, etc. Make sure to check them out.

<!-- TOC -->

## Full page screenshots

Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely.
Expand Down
20 changes: 19 additions & 1 deletion src/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,24 @@ function visit(node, visitor, depth = 0) {
visit(n, visitor, depth + 1);
}

/**
* @param {MarkdownNode[]} nodes
* @param {boolean=} h3
* @returns {string}
*/
function generateToc(nodes, h3) {
const result = [];
visitAll(nodes, (node, depth) => {
if (node.type === 'h1' || node.type === 'h2' || (h3 && node.type === 'h3')) {
let link = node.text.toLowerCase();
link = link.replace(/[ ]+/g, '-');
link = link.replace(/[^\w-_]/g, '');
result.push(`${' '.repeat(depth * 2)}- [${node.text}](#${link})`);
}
});
return result.join('\n');
}

/**
* @param {MarkdownNode[]} nodes
* @param {string} language
Expand Down Expand Up @@ -491,4 +509,4 @@ function filterNodesForLanguage(nodes, language) {
return result;
}

module.exports = { parse, render, clone, visitAll, visit, filterNodesForLanguage, wrapText };
module.exports = { parse, render, clone, visitAll, visit, generateToc, filterNodesForLanguage, wrapText };
Loading