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

[BUG] Cookies get assigned before fulfilling a response #12807

Closed
szmarczak opened this issue Mar 16, 2022 · 4 comments
Closed

[BUG] Cookies get assigned before fulfilling a response #12807

szmarczak opened this issue Mar 16, 2022 · 4 comments
Assignees

Comments

@szmarczak
Copy link
Contributor

Context:

  • Playwright Version: 1.19.2
  • Operating System: Linux
  • Node.js version: v16.13.0
  • Browser: Chromium, Firefox

Code Snippet

const playwright = require('playwright');

(async () => {
        const browser = await playwright.chrome.launchPersistentContext('', {
                headless: false,
        });

        await browser.route('**/*', async (route, request) => {
                try {
                        const response = await request.frame().page().request.fetch(route.request());
                        const responseHeaders = response.headers();

                        delete responseHeaders['set-cookie'];

                        console.log('route not yet fulfilled', (await browser.cookies()).length);

                        route.fulfill({
                                response,
                                headers: responseHeaders,
                        });
                } catch {
                        route.abort('failed');
                }
        });

        const page = await browser.newPage();
        await page.goto('https://www.google.com/');
})();

Describe the bug

Cookies get assigned despite the delete. Replacing set-cookie does not replace the original cookies.

Expected

route not yet fulfilled 0

Actual

route not yet fulfilled 1
@pavelfeldman
Copy link
Member

Thank you for your report. I noticed that

  1. we didn't do a great job at documenting the cookie jar difference, it is only mentioned here: https://playwright.dev/docs/api/class-apirequest.
  2. our documentation for page.request is missing

This should work for you:

const { chromium, request } = require('playwright');

(async () => {
  // Don't use persistent context, it has cookies from previous sessions.
  const browser = await chromium.launch({ headless: false });
  // Create brand new context all the time.
  const context = await browser.newContext();
  await context.route('**/*', async route => {
    // If you use page.fetch, it'll use browser cookie jar, use new request context instead.
    // Create request context with standalone cookie jar.
    const requestContext = await request.newContext();
    const response = await requestContext.fetch(route.request());
    const responseHeaders = response.headers();
    delete responseHeaders['set-cookie'];
    console.log('route not yet fulfilled', (await context.cookies()).length);

    route.fulfill({
      response,
      headers: responseHeaders,
    });
  });
  const page = await context.newPage();
  await page.goto('https://www.apple.com/');
})();

@szmarczak
Copy link
Contributor Author

Thanks for the help, really appreciate it! I'd like to use persistent context anyway due to caching. I saw this piece:

so is await playwright.request.newContext() correct?

@pavelfeldman
Copy link
Member

I'd like to use persistent context anyway due to caching.

Sure, whatever works for you. We would recommend to save/restore storageState, but I'm not sure what your scenario is.

so is await playwright.request.newContext() correct?

Yes, I'm doing it in my snippet above like this: const requestContext = await request.newContext();

@szmarczak
Copy link
Contributor Author

szmarczak commented Mar 27, 2022

I just figured out that context.fetch uses Node.js HTTP API under the hood. This is quite problematic, because it sometimes breaks in very edge cases (the HTTP parser is different, TLS ciphers are different, different API for HTTP2, etc.). You can compare the settings here. So we've come up with https://github.com/apify/got-scraping that tries to mimic the Chrome behavior closely.

Also I noticed that route.continue uses Fetch.continueRequest, but the issue here is that it still overrides the cookie header unless there are no cookies.

bors bot referenced this issue in ttbud/ttbud Dec 11, 2022
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@playwright/test](https://playwright.dev) ([source](https://togithub.com/Microsoft/playwright)) | [`1.15.2` -> `1.28.1`](https://renovatebot.com/diffs/npm/@playwright%2ftest/1.15.2/1.28.1) | [![age](https://badges.renovateapi.com/packages/npm/@playwright%2ftest/1.28.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@playwright%2ftest/1.28.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@playwright%2ftest/1.28.1/compatibility-slim/1.15.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@playwright%2ftest/1.28.1/confidence-slim/1.15.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Microsoft/playwright</summary>

### [`v1.28.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.28.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.28.0...v1.28.1)

#### Highlights

This patch release includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/18928](https://togithub.com/microsoft/playwright/issues/18928) - \[BUG] Electron firstWindow times out after upgrading to 1.28.0[https://github.com/microsoft/playwright/issues/18920](https://togithub.com/microsoft/playwright/issues/18920)0 - \[BUG] \[expanded=false] in role selector returns elements without aria-expanded attribu[https://github.com/microsoft/playwright/issues/18865](https://togithub.com/microsoft/playwright/issues/18865)865 - \[BUG] regression in killing web server process in 1.28.0

#### Browser Versions

-   Chromium 108.0.5359.29
-   Mozilla Firefox 106.0
-   WebKit 16.4

This version was also tested against the following stable channels:

-   Google Chrome 107
-   Microsoft Edge 107

### [`v1.28.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.28.0): v1.28

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.27.1...v1.28.0)

#### Playwright Tools

-   **Record at Cursor in VSCode.** You can run the test, position the cursor at the end of the test and continue generating the test.

<img alt="New VSCode Extension" width=600 src="https://user-images.githubusercontent.com/746130/202005839-aba2eeba-217b-424d-8496-8b4f5fa72f41.png">

-   **Live Locators in VSCode.** You can hover and edit locators in VSCode to get them  highlighted in the opened browser.
-   **Live Locators in CodeGen.** Generate a locator for any element on the page using "Explore" tool.

<img alt="Locator Explorer" src="https://user-images.githubusercontent.com/746130/201796876-01567a0b-ca61-4a9d-b12b-04786c471671.png" width=600>

-   **Codegen and Trace Viewer Dark Theme.** Automatically picked up from operating system settings.

<img alt="Dark Theme" src="https://user-images.githubusercontent.com/746130/201797969-603f74df-d7cf-4c56-befd-798dbd269796.png" width=600>

##### Test Runner

-   Configure retries and test timeout for a file or a test with [`test.describe.configure([options])`](https://playwright.dev/docs/api/class-test#test-describe-configure).

    ```js
    // Each test in the file will be retried twice and have a timeout of 20 seconds.
    test.describe.configure({ retries: 2, timeout: 20_000 });
    test('runs first', async ({ page }) => {});
    test('runs second', async ({ page }) => {});
    ```

-   Use [`testProject.snapshotPathTemplate`](https://playwright.dev/docs/api/class-testproject#test-project-snapshot-path-template) and [`testConfig.snapshotPathTemplate`](https://playwright.dev/docs/api/class-testconfig#test-config-snapshot-path-template) to configure a template controlling location of snapshots generated by [`expect(page).toHaveScreenshot(name[, options])`](https://playwright.dev/docs/test-assertions#page-assertions-to-have-screenshot-1) and [`expect(screenshot).toMatchSnapshot(name[, options])`](https://playwright.dev/docs/test-assertions#screenshot-assertions-to-match-snapshot-1).

    ```js
    // playwright.config.ts
    import type { PlaywrightTestConfig } from '@&#8203;playwright/test';

    const config: PlaywrightTestConfig = {
      testDir: './tests',
      snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
    };

    export default config;
    ```

##### New APIs

-   [`locator.blur([options])`](https://playwright.dev/docs/api/class-locator#locator-blur)
-   [`locator.clear([options])`](https://playwright.dev/docs/api/class-locator#locator-clear)
-   [`android.launchServer([options])`](https://playwright.dev/docs/api/class-android#android-launch-server) and [`android.connect(wsEndpoint[, options])`](https://playwright.dev/docs/api/class-android#android-connect)
-   [`androidDevice.on('close')`](https://playwright.dev/docs/api/class-androiddevice#android-device-event-close)

##### Browser Versions

-   Chromium 108.0.5359.29
-   Mozilla Firefox 106.0
-   WebKit 16.4

This version was also tested against the following stable channels:

-   Google Chrome 107
-   Microsoft Edge 107

### [`v1.27.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.27.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.27.0...v1.27.1)

#### Highlights

This patch release includes the following bug fixes:

[https://github.com/microsoft/playwright/pull/18010](https://togithub.com/microsoft/playwright/pull/18010) - fix(generator): generate nice locators for arbitrary selectors
[https://github.com/microsoft/playwright/pull/17999](https://togithub.com/microsoft/playwright/pull/17999) - chore: don't fail on undefined video/trace
[https://github.com/microsoft/playwright/issues/17955](https://togithub.com/microsoft/playwright/issues/17955) - \[Question] Github Actions test compatibility check failed mitigation?[https://github.com/microsoft/playwright/issues/17960](https://togithub.com/microsoft/playwright/issues/17960)0 - \[BUG] Codegen 1.27 creates NUnit code that does not compil[https://github.com/microsoft/playwright/pull/17952](https://togithub.com/microsoft/playwright/pull/17952)52 - fix: fix typo in treeitem role typing

#### Browser Versions

-   Chromium 107.0.5304.18
-   Mozilla Firefox 105.0.1
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 106
-   Microsoft Edge 106

### [`v1.27.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.27.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.26.1...v1.27.0)

##### Locators

With these new APIs, inspired by [Testing Library](https://testing-library.com/), writing locators is a joy:

-   [`page.getByText(text, options)`](https://playwright.dev/docs/api/class-page#page-get-by-text) to locate by text content.
-   [`page.getByRole(role, options)`](https://playwright.dev/docs/api/class-page#page-get-by-role) to locate by [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
-   [`page.getByLabel(label, options)`](https://playwright.dev/docs/api/class-page#page-get-by-label) to locate a form control by associated label's text.
-   [`page.getByPlaceholder(placeholder, options)`](https://playwright.dev/docs/api/class-page#page-get-by-placeholder) to locate an input by placeholder.
-   [`page.getByAltText(altText, options)`](https://playwright.dev/docs/api/class-page#page-get-by-alt-text) to locate an element, usually image, by its text alternative.
-   [`page.getByTitle(title, options)`](https://playwright.dev/docs/api/class-page#page-get-by-title) to locate an element by its title.

```js
await page.getByLabel('User Name').fill('John');

await page.getByLabel('Password').fill('secret-password');

await page.getByRole('button', { name: 'Sign in' }).click();

await expect(page.getByText('Welcome, John!')).toBeVisible();
```

All the same methods are also available on [Locator](https://playwright.dev/docs/api/class-locator), [FrameLocator](https://playwright.dev/docs/api/class-framelocator) and [Frame](https://playwright.dev/docs/api/class-frame) classes.

##### Other highlights

-   `workers` option in the `playwright.config.ts` now accepts a percentage string to use some of the available CPUs. You can also pass it in the command line:
    ```bash
    npx playwright test --workers=20%
    ```

-   New options `host` and `port` for the html reporter.
    ```js
    reporters: [['html', { host: 'localhost', port: '9223' }]]
    ```

-   New field `FullConfig.configFile` is available to test reporters, specifying the path to the config file if any.

-   As announced in v1.25, Ubuntu 18 will not be supported as of Dec 2022. In addition to that, there will be no WebKit updates on Ubuntu 18 starting from the next Playwright release.

##### Behavior Changes

-   [`expect(locator).toHaveAttribute(name, value, options)`](https://playwright.dev/docs/test-assertions#locator-assertions-to-have-attribute) with an empty value does not match missing attribute anymore. For example, the following snippet will succeed when `button` **does not** have a `disabled` attribute.

    ```js
    await expect(page.getByRole('button')).toHaveAttribute('disabled', '');
    ```

-   Command line options `--grep` and `--grep-invert` previously incorrectly ignored `grep` and `grepInvert` options specified in the config. Now all of them are applied together.

-   JSON reporter path resolution is performed relative to the config directory instead of the current working directory:

    ```js
    ["json", { outputFile: "./test-results/results.json" }]]
    ```

##### Browser Versions

-   Chromium 107.0.5304.18
-   Mozilla Firefox 105.0.1
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 106
-   Microsoft Edge 106

### [`v1.26.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.26.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.26.0...v1.26.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/17500](https://togithub.com/microsoft/playwright/issues/17500) - \[BUG] No tests found using the test explorer - pw/test@1.26.0

#### Browser Versions

-   Chromium 106.0.5249.30
-   Mozilla Firefox 104.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 105
-   Microsoft Edge 105

### [`v1.26.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.26.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.25.2...v1.26.0)

#### Assertions

-   New option enabled for [`expect(locator).toBeEnabled([options])`](https://playwright.dev/docs/test-assertions#locator-assertions-to-be-enabled).
-   [`expect(locator).toHaveText(expected[, options])`](https://playwright.dev/docs/test-assertions#locator-assertions-to-have-text) now pierces open shadow roots.
-   New option editable for [`expect(locator).toBeEditable([options])`](https://playwright.dev/docs/test-assertions#locator-assertions-to-be-editable).
-   New option visible for [`expect(locator).toBeVisible([options])`](https://playwright.dev/docs/test-assertions#locator-assertions-to-be-visible).

#### Other Highlights

-   New option `maxRedirects` for [`apiRequestContext.get(url[, options])`](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-get) and others to limit redirect count.
-   New command-line flag `--pass-with-no-tests` that allows the test suite to pass when no files are found.
-   New command-line flag `--ignore-snapshots` to skip snapshot expectations, such as `expect(value).toMatchSnapshot()` and `expect(page).toHaveScreenshot()`.

#### Behavior Change

A bunch of Playwright APIs already support the waitUntil: 'domcontentloaded' option. For example:

```ts
await page.goto('https://playwright.dev', {
  waitUntil: 'domcontentloaded',
});
```

Prior to 1.26, this would wait for all iframes to fire the `DOMContentLoaded` event.

To align with web specification, the `'domcontentloaded'` value only waits for the target frame to fire the `'DOMContentLoaded'` event. Use `waitUntil: 'load'` to wait for all iframes.

#### Browser Versions

-   Chromium 106.0.5249.30
-   Mozilla Firefox 104.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 105
-   Microsoft Edge 105

### [`v1.25.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.25.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.25.1...v1.25.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/16937](https://togithub.com/microsoft/playwright/issues/16937) - \[REGRESSION]: session storage failing >= 1.25.0 in firefox[https://github.com/microsoft/playwright/issues/16955](https://togithub.com/microsoft/playwright/issues/16955)5 - Not using channel on config file when Show and Reuse browser is checked

#### Browser Versions

-   Chromium 105.0.5195.19
-   Mozilla Firefox 103.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 104
-   Microsoft Edge 104

### [`v1.25.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.25.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.25.0...v1.25.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/16319](https://togithub.com/microsoft/playwright/issues/16319) - \[BUG] webServer.command esbuild fails with ESM and Yarn[https://github.com/microsoft/playwright/issues/16460](https://togithub.com/microsoft/playwright/issues/16460)0 - \[BUG] Component test fails on 2nd run when SSL is use[https://github.com/microsoft/playwright/issues/16665](https://togithub.com/microsoft/playwright/issues/16665)65 - \[BUG] custom selector engines don't work when running in debug mode

#### Browser Versions

-   Chromium 105.0.5195.19
-   Mozilla Firefox 103.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 104
-   Microsoft Edge 104

### [`v1.25.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.25.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.24.2...v1.25.0)

#### VSCode Extension

-   **New Playwright actions view**

    <img width="246" alt="Playwright actions" src="https://user-images.githubusercontent.com/883973/184041259-812722f2-26e3-4561-a972-a1c7973f1332.png">

-   **Pick selector**
    You can pick selector right from a live page, before or after running a test

    <img width="660" alt="Pick selector" src="https://user-images.githubusercontent.com/883973/184041462-288b9458-1650-4789-bd9e-b60d2ccd11dc.png">

-   **Record new test**
    Start recording where you left off with the new 'Record new test' feature.

-   **Show & reuse browser**
    Watch your tests running live & keep devtools open. Develop while continuously running tests.

<img width="660" alt="extension screenshot" src="https://user-images.githubusercontent.com/746130/184043183-1b3932ec-2ca9-4775-a10e-e6fbb20f9a95.jpg">

#### Test Runner

-   [`test.step(title, body)`](https://playwright.dev/docs/api/class-test#test-step) now returns the value of the step function:

    ```ts
    test('should work', async ({ page }) => {
        const pageTitle = await test.step('get title', async () => {
            await page.goto('https://playwright.dev');
            return await page.title();
        });
        console.log(pageTitle);
    });
    ```

-   Added [`test.describe.fixme(title, callback)`](https://playwright.dev/docs/api/class-test#test-describe-fixme).

-   New `'interrupted'` test status.

-   Enable tracing via CLI flag: `npx playwright test --trace=on`.

-   New property [`testCase.id`](https://playwright.dev/docs/api/class-testcase#test-case-id) that can be use in reporters as a history ID.

#### Announcements

-   🎁 We now ship Ubuntu 22.04 Jammy Jellyfish docker image: `mcr.microsoft.com/playwright:v1.25.0-jammy`.
-   🪦 This is the last release with macOS 10.15 support (deprecated as of 1.21).
-   🪦 This is the last release with Node.js 12 support, we recommend upgrading to Node.js LTS (16).
-   ⚠️ Ubuntu 18 is now deprecated and will not be supported as of Dec 2022.

#### Browser Versions

-   Chromium 105.0.5195.19
-   Mozilla Firefox 103.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 104
-   Microsoft Edge 104

### [`v1.24.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.24.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.24.1...v1.24.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/15977](https://togithub.com/microsoft/playwright/issues/15977) - \[BUG] test.use of storage state regression in 1.24

#### Browser Versions

-   Chromium 104.0.5112.48
-   Mozilla Firefox 102.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.24.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.24.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.24.0...v1.24.1)

##### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/15898](https://togithub.com/microsoft/playwright/issues/15898) - \[BUG] Typescript error: The type for webServer config property (TestConfigWebServer) is not typed correctly[https://github.com/microsoft/playwright/issues/15913](https://togithub.com/microsoft/playwright/issues/15913)3 - \[BUG] hooksConfig is required for mount fixtur[https://github.com/microsoft/playwright/issues/15932](https://togithub.com/microsoft/playwright/issues/15932)32 - \[BUG] - Install MS Edge on CI Fails

##### Browser Versions

-   Chromium 104.0.5112.48
-   Mozilla Firefox 102.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.24.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.24.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.23.4...v1.24.0)

#### 🌍 Multiple Web Servers in `playwright.config.ts`

Launch multiple web servers, databases, or other processes by passing an array of configurations:

```ts
// playwright.config.ts
import type { PlaywrightTestConfig } from '@&#8203;playwright/test';
const config: PlaywrightTestConfig = {
  webServer: [
    {
      command: 'npm run start',
      port: 3000,
      timeout: 120 * 1000,
      reuseExistingServer: !process.env.CI,
    },
    {
      command: 'npm run backend',
      port: 3333,
      timeout: 120 * 1000,
      reuseExistingServer: !process.env.CI,
    }
  ],
  use: {
    baseURL: 'http://localhost:3000/',
  },
};
export default config;
```

#### 🐂 Debian 11 Bullseye Support

Playwright now supports Debian 11 Bullseye on x86\_64 for Chromium, Firefox and WebKit. Let us know
if you encounter any issues!

Linux support looks like this:

|          | Ubuntu 18.04 | Ubuntu 20.04 | Ubuntu 22.04 | Debian 11
| :--- | :---: | :---: | :---: | :---: |
| Chromium | ✅ | ✅ | ✅ | ✅ |
| WebKit | ✅ | ✅ | ✅ | ✅ |
| Firefox | ✅ | ✅ | ✅ | ✅ |

#### 🕵️ Anonymous Describe

It is now possible to call [`test.describe(callback)`](https://playwright.dev/docs/api/class-test#test-describe-2) to create suites without a title. This is useful for giving a group of tests a common option with [`test.use(options)`](https://playwright.dev/docs/api/class-test#test-use).

```ts
test.describe(() => {
  test.use({ colorScheme: 'dark' });

  test('one', async ({ page }) => {
    // ...
  });

  test('two', async ({ page }) => {
    // ...
  });
});
```

#### 🧩 Component Tests Update

Playwright 1.24 Component Tests introduce `beforeMount` and `afterMount` hooks.
Use these to configure your app for tests.

##### Vue + Vue Router

For example, this could be used to setup App router in Vue.js:

```js
// src/component.spec.ts
import { test } from '@&#8203;playwright/experimental-ct-vue';
import { Component } from './mycomponent';

test('should work', async ({ mount }) => {
  const component = await mount(Component, {
    hooksConfig: {
      /* anything to configure your app */
    }
  });
});
```

```js
// playwright/index.ts
import { router } from '../router';
import { beforeMount } from '@&#8203;playwright/experimental-ct-vue/hooks';

beforeMount(async ({ app, hooksConfig }) => {
  app.use(router);
});
```

##### React + Next.js

A similar configuration in Next.js would look like this:

```js
// src/component.spec.jsx
import { test } from '@&#8203;playwright/experimental-ct-react';
import { Component } from './mycomponent';

test('should work', async ({ mount }) => {
  const component = await mount(<Component></Component>, {
    // Pass mock value from test into `beforeMount`.
    hooksConfig: {
      router: {
        query: { page: 1, per_page: 10 },
        asPath: '/posts'
      }
    }
  });
});
```

```js
// playwright/index.js
import router from 'next/router';
import { beforeMount } from '@&#8203;playwright/experimental-ct-react/hooks';

beforeMount(async ({ hooksConfig }) => {
  // Before mount, redefine useRouter to return mock value from test.
  router.useRouter = () => hooksConfig.router;
});
```

#### Browser Versions

-   Chromium 104.0.5112.48
-   Mozilla Firefox 102.0
-   WebKit 16.0

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.23.4`](https://togithub.com/microsoft/playwright/releases/tag/v1.23.4)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.23.3...v1.23.4)

#### Highlights

This patch includes the following bug fix:

[https://github.com/microsoft/playwright/issues/15717](https://togithub.com/microsoft/playwright/issues/15717) - \[REGRESSION]: Suddenly stopped working despite nothing having changed (`experimentalLoader.js:load` did not call the next hook in its chain and did not explicitly signal a short circuit)

#### Browser Versions

-   Chromium 104.0.5112.20
-   Mozilla Firefox 100.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.23.3`](https://togithub.com/microsoft/playwright/releases/tag/v1.23.3)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.23.2...v1.23.3)

##### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/15557](https://togithub.com/microsoft/playwright/issues/15557) - \[REGRESSION]: Event Listeners not being removed if same handler is used for different events

##### Browser Versions

-   Chromium 104.0.5112.20
-   Mozilla Firefox 100.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.23.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.23.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.23.1...v1.23.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/15273](https://togithub.com/microsoft/playwright/issues/15273) - \[BUG] LaunchOptions config has no effect after update to v1.23.0[https://github.com/microsoft/playwright/issues/15351](https://togithub.com/microsoft/playwright/issues/15351)1 - \[REGRESSION]: Component testing project does not compile anymor[https://github.com/microsoft/playwright/issues/15431](https://togithub.com/microsoft/playwright/issues/15431)31 - \[BUG] Regression: page.on('console') is ignored in 1.23

#### Browser Versions

-   Chromium 104.0.5112.20
-   Mozilla Firefox 100.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.23.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.23.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.23.0...v1.23.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/15219](https://togithub.com/microsoft/playwright/issues/15219) - \[REGRESSION]: playwright-core 1.23.0 issue with 'TypeError \[ERR_INVALID_ARG_TYPE]: The "listener" argument'

#### Browser Versions

-   Chromium 104.0.5112.20
-   Mozilla Firefox 100.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 103
-   Microsoft Edge 103

### [`v1.23.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.23.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.22.2...v1.23.0)

<a href="https://youtu.be/NRGOV46P3kU"><img src="https://user-images.githubusercontent.com/746130/177854522-a07f4701-9528-4bf9-bf0f-30fbdfb04c8c.png" width=340></a> <a href="https://youtu.be/NRGOV46P3kU">Playwright v1.23 updates</a>

#### Network Replay

Now you can record network traffic into a HAR file and re-use the data in your tests.

To record network into HAR file:

```bash
npx playwright open --save-har=github.har.zip https://github.com/microsoft
```

Alternatively, you can record HAR programmatically:

```ts
const context = await browser.newContext({
  recordHar: { path: 'github.har.zip' }
});
// ... do stuff ...
await context.close();
```

Use the new methods [`page.routeFromHAR()`](https://playwright.dev/docs/api/class-page#page-route-from-har) or [`browserContext.routeFromHAR()`](https://playwright.dev/docs/api/class-browsercontext#browser-context-route-from-har) to serve matching responses from the [HAR](http://www.softwareishard.com/blog/har-12-spec/) file:

```ts
await context.routeFromHAR('github.har.zip');
```

Read more in [our documentation](https://playwright.dev/docs/network#record-and-replay-requests).

##### Advanced Routing

You can now use [`route.fallback()`](https://playwright.dev/docs/api/class-route#route-fallback) to defer routing to other handlers.

Consider the following example:

```ts
// Remove a header from all requests.
test.beforeEach(async ({ page }) => {
  await page.route('**/*', route => {
    const headers = route.request().headers();
    delete headers['if-none-match'];
    route.fallback({ headers });
  });
});

test('should work', async ({ page }) => {
  await page.route('**/*', route => {
    if (route.request().resourceType() === 'image')
      route.abort();
    else
      route.fallback();
  });
});
```

Note that the new methods [`page.routeFromHAR()`](https://playwright.dev/docs/api/class-page#page-route-from-har) and [`browserContext.routeFromHAR()`](https://playwright.dev/docs/api/class-browsercontext#browser-context-route-from-har) also participate in routing and could be deferred to.

##### Web-First Assertions Update

-   New method [`expect(locator).toHaveValues()`](https://playwright.dev/docs/test-assertions#locator-assertions-to-have-values) that asserts all selected values of `<select multiple>` element.
-   Methods [`expect(locator).toContainText()`](https://playwright.dev/docs/test-assertions#locator-assertions-to-contain-text) and [`expect(locator).toHaveText()`](https://playwright.dev/docs/test-assertions#locator-assertions-to-have-text) now accept `ignoreCase` option.

##### Component Tests Update

-   Support for Vue2 via the [`@playwright/experimental-ct-vue2`](https://www.npmjs.com/package/@&#8203;playwright/experimental-ct-vue2) package.
-   Support for component tests for [create-react-app](https://www.npmjs.com/package/create-react-app) with components in `.js` files.

Read more about [component testing with Playwright](https://playwright.dev/docs/test-components).

##### Miscellaneous

-   If there's a service worker that's in your way, you can now easily disable it with a new context option [`serviceWorkers`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-service-workers):
    ```ts
    // playwright.config.ts
    export default {
      use: {
        serviceWorkers: 'block',
      }
    }
    ```
-   Using `.zip` path for [`recordHar`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har) context option automatically zips the resulting HAR:
    ```ts
    const context = await browser.newContext({
      recordHar: {
        path: 'github.har.zip',
      }
    });
    ```
-   If you intend to edit HAR by hand, consider using the `"minimal"` HAR recording mode
    that only records information that is essential for replaying:
    ```ts
    const context = await browser.newContext({
      recordHar: {
        path: 'github.har.zip',
        mode: 'minimal',
      }
    });
    ```
-   Playwright now runs on Ubuntu 22 amd64 and Ubuntu 22 arm64. We also publish new docker image `mcr.microsoft.com/playwright:v1.23.0-focal`.

##### ⚠️ Breaking Changes ⚠️

WebServer is now considered "ready" if request to the specified port has any of the following HTTP status codes:

-   `200-299`
-   `300-399` (new)
-   `400`, `401`, `402`, `403` (new)

### [`v1.22.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.22.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.22.1...v1.22.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/14254](https://togithub.com/microsoft/playwright/issues/14254) - \[BUG] focus() function in version 1.22 closes dropdown (not of select type) instead of just focus on the option

#### Browser Versions

-   Chromium 102.0.5005.40
-   Mozilla Firefox 99.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 101
-   Microsoft Edge 101

### [`v1.22.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.22.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.22.0...v1.22.1)

##### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/14186](https://togithub.com/microsoft/playwright/issues/14186) - \[BUG] expect.toHaveScreenshot() generates an argument error

##### Browser Versions

-   Chromium 102.0.5005.40
-   Mozilla Firefox 99.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 101
-   Microsoft Edge 101

### [`v1.22.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.22.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.21.1...v1.22.0)

#### Introducing Component Testing (preview)

Playwright Test can now test your [React](https://reactjs.org/), [Vue.js](https://vuejs.org/) or [Svelte](https://svelte.dev/) components. You can use all the features of Playwright Test (such as parallelization, emulation & debugging) while running components in real browsers.

<a href="https://youtu.be/y3YxX4sFJbM">![component testing](https://user-images.githubusercontent.com/883973/169662902-deedc95e-12b9-4dfd-b37d-db249910de35.jpg)</a> <a href="https://youtu.be/y3YxX4sFJbM">Component Tests (Preview)</a>

Here is what a typical component test looks like:

```tsx
// App.spec.tsx
import { test, expect } from '@&#8203;playwright/experimental-ct-react';
import App from './App';

// Let's test component in a dark scheme!
test.use({ colorScheme: 'dark' });

test('should render', async ({ mount }) => {
  const component = await mount(<App></App>);

  // As with any Playwright test, assert locator text.
  await expect(component).toContainText('React');
  // Or do a screenshot 🚀
  await expect(component).toHaveScreenshot();
  // Or use any Playwright method
  await component.click();
});
```

Read more in [our documentation](https://playwright.dev/docs/test-components).

***

<a href="https://youtu.be/keV2CIgtBlg">![release update](https://user-images.githubusercontent.com/883973/169663011-23156ebf-c5a9-4eea-91bf-06b555dc60e9.jpg)</a> <a href="https://youtu.be/keV2CIgtBlg">Playwright v1.22 updates</a>

#### Locators Update

-   Role selectors allow selecting elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).

    ```ts
    // Click a button with accessible name "log in"
    await page.click('role=button[name="log in"]')
    ```

    Read more in [our documentation](https://playwright.dev/docs/selectors#role-selector).

-   New [`locator.filter([options])`](https://playwright.dev/docs/api/class-locator#locator-filter) API to filter an existing locator
    ```ts
    const buttons = page.locator('role=button');
    // ...
    const submitButton = buttons.filter({ hasText: 'Submit' });
    await submitButton.click();
    ```

#### Screenshots Update

New web-first assertions [`expect(page).toHaveScreenshot()`](https://playwright.dev/docs/test-assertions#page-assertions-to-have-screenshot) and [`expect(locator).toHaveScreenshot()`](https://playwright.dev/docs/test-assertions#locator-assertions-to-have-screenshot) that wait for screenshot stabilization and enhances test reliability.

The new assertions has screenshot-specific defaults, such as:

-   disables animations
-   uses CSS scale option

```ts
await page.goto('https://playwright.dev');
await expect(page).toHaveScreenshot();
```

The new [`expect(page).toHaveScreenshot()`](https://playwright.dev/docs/test-assertions#page-assertions-to-have-screenshot) saves screenshots at the same location as [`expect(screenshot).toMatchSnapshot()`](https://playwright.dev/docs/test-assertions#screenshot-assertions-to-match-snapshot-1).

#### Browser Versions

-   Chromium 102.0.5005.40
-   Mozilla Firefox 99.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 101
-   Microsoft Edge 101

### [`v1.21.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.21.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.21.0...v1.21.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/pull/13597](https://togithub.com/microsoft/playwright/pull/13597) - \[BUG] fullyParallel created too many workers, slowing down test run[https://github.com/microsoft/playwright/issues/13530](https://togithub.com/microsoft/playwright/issues/13530)0 - \[REGRESSION]: Pull request [#&#8203;12877](https://togithub.com/Microsoft/playwright/issues/12877) prevents the library from being used on any linux distro that is not Ubuntu

#### Browser Versions

-   Chromium 101.0.4951.26
-   Mozilla Firefox 98.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 100
-   Microsoft Edge 100

### [`v1.21.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.21.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.20.2...v1.21.0)

<a href="https://youtu.be/45HZdbmgEw8">![release 1.21](https://user-images.githubusercontent.com/883973/169663514-5f93834a-a0cc-49f8-be11-892010f89f09.jpg)</a> <a href="https://youtu.be/45HZdbmgEw8">Playwright v1.21 updates</a>

#### Highlights

-   New **experimental** role selectors that allow selecting elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).

    ```js
    // Click a button with accessible name "log in"
    await page.click('role=button[name="log in"]')
    ```

    To use role selectors, make sure to pass `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` environment variable:

    ```js
    // playwright.config.js
    process.env.PLAYWRIGHT_EXPERIMENTAL_FEATURES = '1';
    module.exports = {
      /* ... */
    };
    ```

    Read more in [our documentation](https://playwright.dev/docs/selectors#role-selector).

-   New `scale` option in [`Page.screenshot`](https://playwright.dev/docs/api/class-page#page-screenshot) for smaller sized screenshots.

-   New `caret` option in [`Page.screenshot`](https://playwright.dev/docs/api/class-page#page-screenshot) to control text caret. Defaults to `"hide"`.

-   New method `expect.poll` to wait for an arbitrary condition:

    ```js
    // Poll the method until it returns an expected result.
    await expect.poll(async () => {
      const response = await page.request.get('https://api.example.com');
      return response.status();
    }).toBe(200);
    ```

    `expect.poll` supports most synchronous matchers, like `.toBe()`, `.toContain()`, etc.
    Read more in [our documentation](https://playwright.dev/docs/test-assertions#polling).

#### Behavior Changes

-   ESM support when running TypeScript tests is now enabled by default. The `PLAYWRIGHT_EXPERIMENTAL_TS_ESM` env variable is
    no longer required.
-   The `mcr.microsoft.com/playwright` docker image no longer contains Python. Please use `mcr.microsoft.com/playwright/python`
    as a Playwright-ready docker image with pre-installed Python.
-   Playwright now supports large file uploads (100s of MBs) via [`Locator.setInputFiles`](https://playwright.dev/docs/api/class-locator#locator-set-input-files) API.

#### Browser Versions

-   Chromium 101.0.4951.26
-   Mozilla Firefox 98.0.2
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 100
-   Microsoft Edge 100

### [`v1.20.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.20.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.20.1...v1.20.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/13078](https://togithub.com/microsoft/playwright/issues/13078) - \[BUG] Extension required when importing other files with type="module"[https://github.com/microsoft/playwright/issues/13099](https://togithub.com/microsoft/playwright/issues/13099)9 - \[BUG] beforeAll is called before each test (fullyParallel[https://github.com/microsoft/playwright/issues/13204](https://togithub.com/microsoft/playwright/issues/13204)04 - \[BUG] mask stalls the screenshot

#### Browser Versions

-   Chromium 101.0.4921.0
-   Mozilla Firefox 97.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 99
-   Microsoft Edge 99

### [`v1.20.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.20.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.20.0...v1.20.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/12711](https://togithub.com/microsoft/playwright/issues/12711) - \[REGRESSION] Page.screenshot hangs on some sites[https://github.com/microsoft/playwright/issues/12807](https://togithub.com/microsoft/playwright/issues/12807)7 - \[BUG] Cookies get assigned before fulfilling a respons[https://github.com/microsoft/playwright/issues/12814](https://togithub.com/microsoft/playwright/issues/12814)14 - \[Question] how to use expect.any in playwrig[https://github.com/microsoft/playwright/issues/12821](https://togithub.com/microsoft/playwright/issues/12821)821 - \[BUG] Chromium: Cannot click, element intercepts pointer eve[https://github.com/microsoft/playwright/issues/12836](https://togithub.com/microsoft/playwright/issues/12836)2836 - \[REGRESSION]: Tests not detected as ES module in v[https://github.com/microsoft/playwright/issues/12862](https://togithub.com/microsoft/playwright/issues/12862)12862 - \[Feature] Allow to use toMatchSnapshot for file formats other than txt (e.g.[https://github.com/microsoft/playwright/issues/12887](https://togithub.com/microsoft/playwright/issues/12887)/12887 - \[BUG] Locator.count() with \_vue selector wit[https://github.com/microsoft/playwright/issues/12940](https://togithub.com/microsoft/playwright/issues/12940)es/12940 - \[BUG] npm audit - High Severity vulnerability in json5 package forcing to install Playwrigh[https://github.com/microsoft/playwright/issues/12974](https://togithub.com/microsoft/playwright/issues/12974)ues/12974 - \[BUG] Regression - chromium browser closes during test or debugging session on macos

#### Browser Versions

-   Chromium 101.0.4921.0
-   Mozilla Firefox 97.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 99
-   Microsoft Edge 99

### [`v1.20.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.20.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.19.2...v1.20.0)

<a href="https://youtu.be/6vV-XXKsrbA">![release-1.20](https://user-images.githubusercontent.com/883973/169663565-0b99510a-cca2-44f6-8c49-60c9569eb0a5.jpg)</a> <a href="https://youtu.be/6vV-XXKsrbA">Playwright v1.20 updates</a>

#### Highlights

-   New options for methods [`page.screenshot()`](https://playwright.dev/docs/api/class-page#page-screenshot), [`locator.screenshot()`](https://playwright.dev/docs/api/class-locator#locator-screenshot) and [`elementHandle.screenshot()`](https://playwright.dev/docs/api/class-elementhandle#element-handle-screenshot):
    -   Option `animations: "disabled"` rewinds all CSS animations and transitions to a consistent state.
    -   Option `mask: Locator[]` masks given elements, overlaying them with pink `#FF00FF` boxes.

-   [`expect().toMatchSnapshot()`](https://playwright.dev/docs/test-assertions#screenshot-assertions-to-match-snapshot) now supports anonymous snapshots: when snapshot name is missing, Playwright Test will generate one
    automatically:

    ```js
    expect('Web is Awesome <3').toMatchSnapshot();
    ```

-   New `maxDiffPixels` and `maxDiffPixelRatio` options for fine-grained screenshot comparison using [`expect().toMatchSnapshot()`](https://playwright.dev/docs/test-assertions#screenshot-assertions-to-match-snapshot):

    ```js
    expect(await page.screenshot()).toMatchSnapshot({
      maxDiffPixels: 27, // allow no more than 27 different pixels.
    });
    ```

    It is most convenient to specify `maxDiffPixels` or `maxDiffPixelRatio` once in [`TestConfig.expect`](https://playwright.dev/docs/api/class-testconfig#test-config-expect).

-   Playwright Test now adds [`TestConfig.fullyParallel`](https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel) mode. By default, Playwright Test parallelizes between files. In fully parallel mode, tests inside a single file are also run in parallel. You can also use `--fully-parallel` command line flag.

    ```ts
    // playwright.config.ts
    export default {
      fullyParallel: true,
    };
    ```

-   [`TestProject.grep`](https://playwright.dev/docs/api/class-testproject#test-project-grep) and [`TestProject.grepInvert`](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert) are now configurable per project. For example, you can now
    configure smoke tests project using `grep`:
    ```ts
    // playwright.config.ts
    export default {
      projects: [
        {
          name: 'smoke tests',
          grep: /@&#8203;smoke/,
        },
      ],
    };
    ```

-   [Trace Viewer](https://playwright.dev/docs/trace-viewer) now shows [API testing requests](https://playwright.dev/docs/test-api-testing).

-   [`locator.highlight()`](https://playwright.dev/docs/api/class-locator#locator-highlight) visually reveals element(s) for easier debugging.

#### Announcements

-   We now ship a designated Python docker image `mcr.microsoft.com/playwright/python`. Please switch over to it if you use Python. This is the last release that includes Python inside our javascript `mcr.microsoft.com/playwright` docker image.
-   v1.20 is the last release to receive WebKit update for macOS 10.15 Catalina. Please update MacOS to keep using latest & greatest WebKit!

#### Browser Versions

-   Chromium 101.0.4921.0
-   Mozilla Firefox 97.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 99
-   Microsoft Edge 99

### [`v1.19.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.19.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.19.1...v1.19.2)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/12091](https://togithub.com/microsoft/playwright/issues/12091) - \[BUG] playwright 1.19.0 generates more than 1 trace file per test[https://github.com/microsoft/playwright/issues/12106](https://togithub.com/microsoft/playwright/issues/12106)6 - \[BUG] Error: EBUSY: resource busy or locked when using volumes in docker-compose with playwright 1.19.0 and mcr.microsoft.com/playwright:v1.15.0-focal

#### Browser Versions

-   Chromium 100.0.4863.0
-   Mozilla Firefox 96.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 98
-   Microsoft Edge 98

### [`v1.19.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.19.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.19.0...v1.19.1)

#### Highlights

This patch includes the following bug fixes:

[https://github.com/microsoft/playwright/issues/12075](https://togithub.com/microsoft/playwright/issues/12075) - \[Question] After update to 1.19 firefox fails to run[https://github.com/microsoft/playwright/issues/12090](https://togithub.com/microsoft/playwright/issues/12090)0 - \[BUG] did something change on APIRequest/Response APIs ?

#### Browser Versions

-   Chromium 100.0.4863.0
-   Mozilla Firefox 96.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 98
-   Microsoft Edge 98

### [`v1.19.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.19.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.18.1...v1.19.0)

<a href="https://youtu.be/z0EOFvlf14U">![release-1.19](https://user-images.githubusercontent.com/883973/169663681-d82de420-fd32-4280-9431-8deea1efd5f3.jpg)</a> <a href="https://youtu.be/z0EOFvlf14U">Playwright v1.19 updates</a>

##### Playwright Test Updates

##### Soft assertions

Playwright Test v1.19 now supports **soft assertions**. Failed soft assertions **do not** terminate test execution, but mark the test as failed. Read more in [our documentation](https://playwright.dev/docs/test-assertions#soft-assertions).

```js
// Make a few checks that will not stop the test when failed...
await expect.soft(page.locator('#status')).toHaveText('Success');
await expect.soft(page.locator('#eta')).toHaveText('1 day');

// ... and continue the test to check more things.
await page.locator('#next-page').click();
await expect.soft(page.locator('#title')).toHaveText('Make another order');
```

##### Custom error messages

You can now specify a [**custom error message**](https://playwright.dev/docs/test-assertions#custom-error-message) as a second argument to the `expect` and `expect.soft` functions, for example:

```js
await expect(page.locator('text=Name'), 'should be logged in').toBeVisible();
```

The error would look like this:

```bash
    Error: should be logged in

    Call log:
      - expect.toBeVisible with timeout 5000ms
      - waiting for selector "text=Name"

      2 |
      3 | test('example test', async({ page }) => {
    > 4 |   await expect(page.locator('text=Name'), 'should be logged in').toBeVisible();
        |                                                                  ^
      5 | });
      6 |
```

##### Parallel mode in file

By default, tests in a single file are run in order. If you have many independent tests in a single file, you can now
run them in parallel with [`method: test.describe.configure`](https://playwright.dev/docs/api/class-test#test-describe-configure):

```js
import { test } from '@&#8203;playwright/test';

test.describe.configure({ mode: 'parallel' });

test('parallel 1', async () => {});
test('parallel 2', async () => {});
```

##### [⚠️](https://emojipedia.org/warning/#:~:text=A%20triangle%20with%20an%20exclamation,to%20Emoji%201.0%20in%202015.) Potentially breaking change in Playwright Test Global Setup

It is unlikely that this change will affect you, no action is required if your tests keep running as they did.

We've noticed that in rare cases, the set of tests to be executed was configured in the global setup by means of the environment variables. We also noticed some applications that were post processing the reporters' output in the global teardown. If you are doing one of the two, [learn more](https://togithub.com/microsoft/playwright/issues/12018)

##### Locator Updates

##### Locator now supports a `has` option that makes sure it contains another locator inside:

```js
await page.locator('article', {
  has: page.locator('.highlight'),
}).locator('button').click();
```

The snippet above will select article that has highlight in it and will press the button in it.
Read more in [locator documentation](https://playwright.dev/docs/api/class-locator#locator-locator-option-has)

##### Other Updates

-   New [`method: Locator.page`](https://playwright.dev/docs/api/class-locator#locator-page)
-   [`method: Page.screenshot`](https://playwright.dev/docs/api/class-page#page-screenshot) and [`method: Locator.screenshot`](https://playwright.dev/docs/api/class-locator#locator-screenshot) now automatically hides blinking caret
-   Playwright Codegen now generates locators and frame locators
-   New option `url`  in [`testConfig.webServer`](https://playwright.dev/docs/api/class-testconfig#test-config-web-server) to ensure your web server is ready before running the tests
-   New [`property: TestInfo.errors`](https://playwright.dev/docs/api/class-testinfo#test-info-errors) and [`property: TestResult.errors`](https://playwright.dev/docs/api/class-testresult#test-result-errors) that contain all failed assertions and soft assertions.

#### Browser Versions

-   Chromium 100.0.4863.0
-   Mozilla Firefox 96.0.1
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 98
-   Microsoft Edge 98

***

### [`v1.18.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.18.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.18.0...v1.18.1)

#### Highlights

This patch includes improvements to the TypeScript support and the following bug fixes:

[https://github.com/microsoft/playwright/issues/11550](https://togithub.com/microsoft/playwright/issues/11550) - \[REGRESSION]: Errors inside route handler does not lead to unhandled rejections anymore[https://github.com/microsoft/playwright/issues/11552](https://togithub.com/microsoft/playwright/issues/11552)2 - \[BUG] Could not resolve "C:\repo\framework\utils" in file C:\repo\tests\test.ts.

#### Browser Versions

-   Chromium 99.0.4812.0
-   Mozilla Firefox 95.0
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 97
-   Microsoft Edge 97

### [`v1.18.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.18.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.17.2...v1.18.0)

<a href="https://youtu.be/ABLYpw2BN_g">![release-1.18](https://user-images.githubusercontent.com/883973/169663725-400d1b08-7278-4322-9d42-8e4ec1199a9a.jpg)</a> <a href="https://youtu.be/ABLYpw2BN_g">Playwright v1.18 updates</a>

#### Locator Improvements

-   [`locator.dragTo(locator)`][locator.dragTo(locator)]
-   [`expect(locator).toBeChecked({ checked })`][expect(locator).toBeChecked({ checked })]
-   Each locator can now be optionally filtered by the text it contains:
    ```js
    await page.locator('li', { hasText: 'my item' }).locator('button').click();
    ```
    Read more in [locator documentation].

#### Testing API improvements

-   [`expect(response).toBeOK()`][expect(response).toBeOK()]
-   [`testInfo.attach()`][testInfo.attach()]
-   [`test.info()`][test.info()]

#### Improved TypeScript Support

1.  Playwright Test now respects `tsconfig.json`'s [`baseUrl`](https://www.typescriptlang.org/tsconfig#baseUrl) and [`paths`](https://www.typescriptlang.org/tsconfig#paths), so you can use aliases
2.  There is a new environment variable `PW_EXPERIMENTAL_TS_ESM` that allows importing ESM modules in your TS code, without the need for the compile step. Don't forget the `.js` suffix when you are importing your esm modules. Run your tests as follows:

```bash
npm i --save-dev @&#8203;playwright/test@1.18.0
PW_EXPERIMENTAL_TS_ESM=1 npx playwright test
```

#### Create Playwright

The `npm init playwright` command is now generally available for your use:

```sh

### Run from your project's root directory
npm init playwright

### Or create a new project
npm init playwright new-project
```

This will scaffold everything needed to get started with Playwright Test: configuration file, optionally add examples, a GitHub Action workflow and a first test `example.spec.ts`.

#### New APIs & changes

-   new [`testCase.repeatEachIndex`][testCase.repeatEachIndex] API
-   [`acceptDownloads`][acceptDownloads] option now defaults to `true`

#### Breaking change: custom config options

Custom config options are a convenient way to parametrize projects with different values. Learn more in the [parametrization guide].

Previously, any fixture introduced through [`test.extend`][test.extend] could be overridden in the [`testProject.use`][testProject.use] config section. For example,

```js
// WRONG: THIS SNIPPET DOES NOT WORK SINCE v1.18.

// fixtures.js
const test = base.extend({
  myParameter: 'default',
});

// playwright.config.js
module.exports = {
  use: {
    myParameter: 'value',
  },
};
```

The proper way to make a fixture parametrized in the config file is to specify `option: true` when defining the fixture. For example,

```js
// CORRECT: THIS SNIPPET WORKS SINCE v1.18.

// fixtures.js
const test = base.extend({
  // Fixtures marked as "option: true" will get a value specified in the config,
  // or fallback to the default value.
  myParameter: ['default', { option: true }],
});

// playwright.config.js
module.exports = {
  use: {
    myParameter: 'value',
  },
};
```

#### Browser Versions

-   Chromium 99.0.4812.0
-   Mozilla Firefox 95.0
-   WebKit 15.4

This version was also tested against the following stable channels:

-   Google Chrome 97
-   Microsoft Edge 97

***

[`locator.dragTo(locator)`]: https://playwright.dev/docs/api/class-locator#locator-drag-to

[`expect(locator).toBeChecked({ checked })`]: https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-be-checked

[locator documentation]: https://playwright.dev/docs/api/class-locator#locator-locator-option-has-text

[`expect(response).toBeOK()`]: https://playwright.dev/docs/api/class-apiresponseassertions

[`testInfo.attach()`]: https://playwright.dev/docs/api/class-testinfo#test-info-attach

[`test.info()`]: https://playwright.dev/docs/api/class-test#test-info

[`testCase.repeatEachIndex`]: https://playwright.dev/docs/api/class-testcase#test-case-repeat-each-index

[parametrization guide]: https://playwright.dev/docs/test-parameterize#parameterized-projects

[`acceptDownloads`]: https://playwright.dev/docs/api/class-browser#browser-new-context-option-accept-downloads

[`test.extend`]: https://playwright.dev/docs/api/class-test#test-extend

[`testProject.use`]: https://playwright.dev/docs/api/class-testproject#test-project-use

(`1.18.0-beta-1642620709000`)

### [`v1.17.2`](https://togithub.com/microsoft/playwright/releases/tag/v1.17.2)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.17.1...v1.17.2)

#### Bugfixes

[#&#8203;11274](https://togithub.com/Microsoft/playwright/issues/11274) - fix: pin colors to 1.4.0
[#&#8203;11228](https://togithub.com/Microsoft/playwright/issues/11228) - fix(click): don't fail on stale context while click

### [`v1.17.1`](https://togithub.com/microsoft/playwright/releases/tag/v1.17.1)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.17.0...v1.17.1)

#### Highlights

This patch includes bug fixes for the following issues:

[https://github.com/microsoft/playwright/issues/10638](https://togithub.com/microsoft/playwright/issues/10638) - \[BUG] Locator.click -> subtree intercepts pointer events since version 1.17.0[https://github.com/microsoft/playwright/issues/10632](https://togithub.com/microsoft/playwright/issues/10632)2 - \[BUG] Playwright 1.17.0 -> After clicking the element - I get an error that click action was faile[https://github.com/microsoft/playwright/issues/10627](https://togithub.com/microsoft/playwright/issues/10627)27 - \[REGRESSION]: Can no longer click Material UI select b[https://github.com/microsoft/playwright/issues/10620](https://togithub.com/microsoft/playwright/issues/10620)620 - \[BUG] trailing zero width whitespace fails toHaveText

#### Browser Versions

-   Chromium 98.0.4695.0
-   Mozilla Firefox 94.0.1
-   WebKit 15.4

This version of Playwright was also tested against the following stable channels:

-   Google Chrome 96
-   Microsoft Edge 96

***

(1.17.1)

### [`v1.17.0`](https://togithub.com/microsoft/playwright/releases/tag/v1.17.0)

[Compare Source](https://togithub.com/Microsoft/playwright/compare/v1.16.3...v1.17.0)

<a href="https://youtu.be/7iyIdeoAP04">![release-1.17](https://user-images.githubusercontent.com/883973/169663759-f810a03f-6488-436a-835a-21d18bed8fb1.jpg)</a> <a href="https://youtu.be/7iyIdeoAP04">Playwright v1.17 updates</a>

#### Frame Locators

Playwright 1.17 introduces [frame locators] - a locator to the iframe on the page. Frame locators capture the logic sufficient to retrieve the `iframe` and then locate elements in that iframe. Frame locators are strict by default, will wait for `iframe` to appear and can be used in Web-First assertions.

![Graphics](https://user-images.githubusercontent.com/746130/142082759-2170db38-370d-43ec-8d41-5f9941f57d83.png)

Frame locators can be created with either [`page.frameLocator(selector)`][page.frameLocator(selector)] or [`locator.frameLocator(selector)`][locator.frameLocator(selector)] method.

```js
const locator = page.frameLocator('#my-iframe').locator('text=Submit');
await locator.click();
```

Read more at [our documentation](https://playwright.dev/docs/next/api/class-framelocator).

#### Trace Viewer Update

Playwright Trace Viewer is now **available online** at https://trace.playwright.dev! Just drag-and-drop your `trace.zip` file to inspect its contents.

> **NOTE**: trace files are not uploaded anywhere; [trace.playwright.dev](https://trace.playwright.dev) is a [progressive web application](https://web.dev/progressive-web-apps/) that processes traces locally.

-

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ttbud/ttbud).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDIuNCIsInVwZGF0ZWRJblZlciI6IjM0LjUxLjAifQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants