Skip to content

Commit

Permalink
feat(roll): roll to ToT Playwright (18-05-24) (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
playwrightmachine committed May 18, 2024
1 parent bfefdc2 commit 940e72d
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 28 deletions.
75 changes: 75 additions & 0 deletions dotnet/docs/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,81 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';

## Version 1.44

### New APIs

**Accessibility assertions**
- [Expect(Locator).ToHaveAccessibleNameAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-name) checks if the element has the specified accessible name:

```csharp
var locator = Page.GetByRole(AriaRole.Button);
await Expect(locator).ToHaveAccessibleNameAsync("Submit");
```

- [Expect(Locator).ToHaveAccessibleDescriptionAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-description) checks if the element has the specified accessible description:

```csharp
var locator = Page.GetByRole(AriaRole.Button);
await Expect(locator).ToHaveAccessibleDescriptionAsync("Upload a photo");
```

- [Expect(Locator).ToHaveRoleAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-role) checks if the element has the specified ARIA role:

```csharp
var locator = Page.GetByTestId("save-button");
await Expect(locator).ToHaveRoleAsync(AriaRole.Button);
```

**Locator handler**
- After executing the handler added with [Page.AddLocatorHandlerAsync()](/api/class-page.mdx#page-add-locator-handler), Playwright will now wait until the overlay that triggered the handler is not visible anymore. You can opt-out of this behavior with the new `NoWaitAfter` option.
- You can use new `Times` option in [Page.AddLocatorHandlerAsync()](/api/class-page.mdx#page-add-locator-handler) to specify maximum number of times the handler should be run.
- The handler in [Page.AddLocatorHandlerAsync()](/api/class-page.mdx#page-add-locator-handler) now accepts the locator as argument.
- New [Page.RemoveLocatorHandlerAsync()](/api/class-page.mdx#page-remove-locator-handler) method for removing previously added locator handlers.

```csharp
var locator = Page.GetByText("This interstitial covers the button");
await Page.AddLocatorHandlerAsync(locator, async (overlay) =>
{
await overlay.Locator("#close").ClickAsync();
}, new() { Times = 3, NoWaitAfter = true });
// Run your tests that can be interrupted by the overlay.
// ...
await Page.RemoveLocatorHandlerAsync(locator);
```

**Miscellaneous options**
- New method [FormData.Append()](/api/class-formdata.mdx#form-data-append) allows to specify repeating fields with the same name in [`Multipart`](./api/class-apirequestcontext#api-request-context-fetch-option-multipart) option in `APIRequestContext.FetchAsync()`:
- ```
```csharp
var formData = Context.APIRequest.CreateFormData();
formData.Append("file", new FilePayload()
{
Name = "f1.js",
MimeType = "text/javascript",
Buffer = System.Text.Encoding.UTF8.GetBytes("var x = 2024;")
});
formData.Append("file", new FilePayload()
{
Name = "f2.txt",
MimeType = "text/plain",
Buffer = System.Text.Encoding.UTF8.GetBytes("hello")
});
var response = await Context.APIRequest.PostAsync("https://example.com/uploadFiles", new() { Multipart = formData });
```

- [Expect(Page).ToHaveURLAsync()](/api/class-pageassertions.mdx#page-assertions-to-have-url) now supports `IgnoreCase` [option](./api/class-pageassertions#page-assertions-to-have-url-option-ignore-case).

### Browser Versions
* Chromium 125.0.6422.14
* Mozilla Firefox 125.0.1
* WebKit 17.4

This version was also tested against the following stable channels:
* Google Chrome 124
* Microsoft Edge 124

## Version 1.43

### New APIs
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.43.0-jammy
image: mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy
container: mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy
- image: mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy' } }
agent { docker { image 'mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy
image: mcr.microsoft.com/playwright/java:v1.44.0-jammy
```

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

tests:
stage: test
image: mcr.microsoft.com/playwright/java:v1.43.0-jammy
image: mcr.microsoft.com/playwright/java:v1.44.0-jammy
script:
...
```
Expand Down
12 changes: 6 additions & 6 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.43.0-jammy
docker pull mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.44.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.43.0-jammy /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.44.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,9 +76,9 @@ 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.43.0` - Playwright v1.43.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.43.0-jammy` - Playwright v1.43.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.43.0-focal` - Playwright v1.43.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.44.0` - Playwright v1.44.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.44.0-jammy` - Playwright v1.44.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.44.0-focal` - Playwright v1.44.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.43.0</version>
<version>1.44.0</version>
</dependency>
</dependencies>
<build>
Expand Down
65 changes: 65 additions & 0 deletions java/docs/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,71 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';

## Version 1.44

### New APIs

**Accessibility assertions**
- [assertThat(locator).hasAccessibleName()](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-name) checks if the element has the specified accessible name:

```java
Locator locator = page.getByRole(AriaRole.BUTTON);
assertThat(locator).hasAccessibleName("Submit");
```

- [assertThat(locator).hasAccessibleDescription()](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-description) checks if the element has the specified accessible description:

```java
Locator locator = page.getByRole(AriaRole.BUTTON);
assertThat(locator).hasAccessibleDescription("Upload a photo");
```

- [assertThat(locator).hasRole()](/api/class-locatorassertions.mdx#locator-assertions-to-have-role) checks if the element has the specified ARIA role:

```java
Locator locator = page.getByTestId("save-button");
assertThat(locator).hasRole(AriaRole.BUTTON);
```

**Locator handler**
- After executing the handler added with [Page.addLocatorHandler()](/api/class-page.mdx#page-add-locator-handler), Playwright will now wait until the overlay that triggered the handler is not visible anymore. You can opt-out of this behavior with the new `setNoWaitAfter` option.
- You can use new `setTimes` option in [Page.addLocatorHandler()](/api/class-page.mdx#page-add-locator-handler) to specify maximum number of times the handler should be run.
- The handler in [Page.addLocatorHandler()](/api/class-page.mdx#page-add-locator-handler) now accepts the locator as argument.
- New [Page.removeLocatorHandler()](/api/class-page.mdx#page-remove-locator-handler) method for removing previously added locator handlers.

```java
Locator locator = page.getByText("This interstitial covers the button");
page.addLocatorHandler(locator, overlay -> {
overlay.locator("#close").click();
}, new Page.AddLocatorHandlerOptions().setTimes(3).setNoWaitAfter(true));
// Run your tests that can be interrupted by the overlay.
// ...
page.removeLocatorHandler(locator);
```

**Miscellaneous options**
- New method [FormData.append()](/api/class-formdata.mdx#form-data-append) allows to specify repeating fields with the same name in [`setMultipart`](./api/class-requestoptions#request-options-set-multipart) option in `RequestOptions`:

```java
FormData formData = FormData.create();
formData.append("file", new FilePayload("f1.js", "text/javascript",
"var x = 2024;".getBytes(StandardCharsets.UTF_8)));
formData.append("file", new FilePayload("f2.txt", "text/plain",
"hello".getBytes(StandardCharsets.UTF_8)));
APIResponse response = context.request().post("https://example.com/uploadFile", RequestOptions.create().setMultipart(formData));
```

- `expect(page).toHaveURL(url)` now supports `setIgnoreCase` [option](./api/class-pageassertions#page-assertions-to-have-url-option-ignore-case).

### Browser Versions
* Chromium 125.0.6422.14
* Mozilla Firefox 125.0.1
* WebKit 17.4

This version was also tested against the following stable channels:
* Google Chrome 124
* Microsoft Edge 124

## Version 1.43

### New APIs
Expand Down
4 changes: 2 additions & 2 deletions java/docs/test-runners.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ repositories {
}

dependencies {
implementation 'com.microsoft.playwright:playwright:1.43.0'
implementation 'com.microsoft.playwright:playwright:1.44.0'
}

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

dependencies {
implementation("com.microsoft.playwright:playwright:1.43.0")
implementation("com.microsoft.playwright:playwright:1.44.0")
}

application {
Expand Down
2 changes: 1 addition & 1 deletion python/docs/ci-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/python:v1.43.0-jammy
image: mcr.microsoft.com/playwright/python:v1.44.0-jammy
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
10 changes: 5 additions & 5 deletions python/docs/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ trigger:

pool:
vmImage: ubuntu-latest
container: mcr.microsoft.com/playwright/python:v1.43.0-jammy
container: mcr.microsoft.com/playwright/python:v1.44.0-jammy

steps:
- task: UsePythonVersion@0
Expand All @@ -104,7 +104,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In
executors:
pw-jammy-development:
docker:
- image: mcr.microsoft.com/playwright/python:v1.43.0-jammy
- image: mcr.microsoft.com/playwright/python:v1.44.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 @@ -115,7 +115,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/python:v1.43.0-jammy' } }
agent { docker { image 'mcr.microsoft.com/playwright/python:v1.44.0-jammy' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -132,7 +132,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/python:v1.43.0-jammy
image: mcr.microsoft.com/playwright/python:v1.44.0-jammy
```

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

tests:
stage: test
image: mcr.microsoft.com/playwright/python:v1.43.0-jammy
image: mcr.microsoft.com/playwright/python:v1.44.0-jammy
script:
...
```
Expand Down
14 changes: 7 additions & 7 deletions python/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/python:v1.43.0-jammy
docker pull mcr.microsoft.com/playwright/python:v1.44.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/python:v1.43.0-jammy /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/python:v1.44.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/python:v1.43.0-jammy /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/python:v1.44.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,9 +76,9 @@ 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.43.0` - Playwright v1.43.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.43.0-jammy` - Playwright v1.43.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.43.0-focal` - Playwright v1.43.0 release docker image based on Ubuntu 20.04 LTS (Focal Fossa).
- `:v1.44.0` - Playwright v1.44.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.44.0-jammy` - Playwright v1.44.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.44.0-focal` - Playwright v1.44.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 All @@ -101,7 +101,7 @@ To run Playwright inside Docker, you need to have Python, [Playwright browsers](
```Dockerfile
FROM python:3.12-bookworm

RUN pip install playwright==@1.43.0 && \
RUN pip install playwright==@1.44.0 && \
playwright install --with-deps
```

Expand Down

0 comments on commit 940e72d

Please sign in to comment.