From acbc70d8375f9c543c66dca83159476c7f98a4d3 Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Mon, 19 Sep 2022 03:40:09 -0700 Subject: [PATCH] feat(roll): roll to ToT Playwright (19-09-22) (#782) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- dotnet/docs/release-notes.mdx | 27 ----------- dotnet/docs/test-assertions.mdx | 34 +++---------- java/docs/release-notes.mdx | 21 -------- java/docs/test-assertions.mdx | 33 +++---------- nodejs/docs/release-notes.mdx | 1 - nodejs/docs/test-assertions.mdx | 36 +++----------- nodejs/docs/test-components.mdx | 75 +++++++++++++++++++++++----- python/docs/release-notes.mdx | 25 ---------- python/docs/test-assertions.mdx | 86 ++++++--------------------------- 9 files changed, 103 insertions(+), 235 deletions(-) diff --git a/dotnet/docs/release-notes.mdx b/dotnet/docs/release-notes.mdx index 9d63336eaa4f5..ea057ec99c181 100644 --- a/dotnet/docs/release-notes.mdx +++ b/dotnet/docs/release-notes.mdx @@ -4,33 +4,6 @@ title: "Release notes" toc_max_heading_level: 2 --- -## Version 1.26 - -### Assertions -- [Expect(Locator).ToHaveAttributeAsync(name, options)](/test-assertions.mdx#locator-assertions-to-have-attribute-2) can now be used for asserting attribute existence. -- New option `Enabled` for [Expect(Locator).ToBeEnabledAsync(options)](/test-assertions.mdx#locator-assertions-to-be-enabled). -- [Expect(Locator).ToHaveTextAsync(expected, options)](/test-assertions.mdx#locator-assertions-to-have-text) now pierces open shadow roots. -- New option `Editable` for [Expect(Locator).ToBeEditableAsync(options)](/test-assertions.mdx#locator-assertions-to-be-editable). -- New option `Visible` for [Expect(Locator).ToBeVisibleAsync(options)](/test-assertions.mdx#locator-assertions-to-be-visible). -- [Expect(ApiResponse).ToBeOKAsync()](/test-assertions.mdx#api-response-assertions-to-be-ok) is now available. - -### Other highlights -- New option `MaxRedirects` for [ApiRequestContext.GetAsync(url, options)](/api/class-apirequestcontext.mdx#api-request-context-get) and others to limit redirect count. -- Codegen now supports NUnit and MSTest frameworks. -- ASP .NET is now supported. - -### Behavior Change - -A bunch of Playwright APIs already support the `WaitUntil: WaitUntilState.DOMContentLoaded` option. For example: - -```csharp -await Page.GotoAsync("https://playwright.dev", new() { WaitUntil = WaitUntilState.DOMContentLoaded }); -``` - -Prior to 1.26, this would wait for all iframes to fire the `DOMContentLoaded` event. - -To align with web specification, the `WaitUntilState.DOMContentLoaded` value only waits for the target frame to fire the `'DOMContentLoaded'` event. Use `WaitUntil: WaitUntilState.Load` to wait for all iframes. - ## Version 1.25 ### New .runsettings file support diff --git a/dotnet/docs/test-assertions.mdx b/dotnet/docs/test-assertions.mdx index 0347dd46bf8d7..34dc926b5d9c8 100644 --- a/dotnet/docs/test-assertions.mdx +++ b/dotnet/docs/test-assertions.mdx @@ -40,8 +40,7 @@ By default, the timeout for assertions is set to 5 seconds. - [Expect(Locator).ToBeHiddenAsync(options)](/test-assertions.mdx#locator-assertions-to-be-hidden) - [Expect(Locator).ToBeVisibleAsync(options)](/test-assertions.mdx#locator-assertions-to-be-visible) - [Expect(Locator).ToContainTextAsync(expected, options)](/test-assertions.mdx#locator-assertions-to-contain-text) -- [Expect(Locator).ToHaveAttributeAsync(name, value, options)](/test-assertions.mdx#locator-assertions-to-have-attribute-1) -- [Expect(Locator).ToHaveAttributeAsync(name, options)](/test-assertions.mdx#locator-assertions-to-have-attribute-2) +- [Expect(Locator).ToHaveAttributeAsync(name, value, options)](/test-assertions.mdx#locator-assertions-to-have-attribute) - [Expect(Locator).ToHaveClassAsync(expected, options)](/test-assertions.mdx#locator-assertions-to-have-class) - [Expect(Locator).ToHaveCountAsync(count, options)](/test-assertions.mdx#locator-assertions-to-have-count) - [Expect(Locator).ToHaveCSSAsync(name, value, options)](/test-assertions.mdx#locator-assertions-to-have-css) @@ -244,40 +243,23 @@ await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Some 33" await Expect(Page.Locator("ul")).ToContainTextAsync(new string[] {"Text 3"}); ``` -## Expect(Locator).ToHaveAttributeAsync(name, value, options) {#locator-assertions-to-have-attribute-1} +## Expect(Locator).ToHaveAttributeAsync(name, value, options) {#locator-assertions-to-have-attribute} -Added in: v1.18 +Added in: v1.20 -- `name`# -- `value`# +- `name`# +- `value`# - `options` <`LocatorAssertionsToHaveAttributeOptions?`> - - `Timeout`# -- returns:# + - `Timeout`# +- returns:# -Ensures the [Locator] points to an element with given attribute value. +Ensures the [Locator] points to an element with given attribute. ```csharp var locator = Page.Locator("input"); await Expect(locator).ToHaveAttributeAsync("type", "text"); ``` -## Expect(Locator).ToHaveAttributeAsync(name, options) {#locator-assertions-to-have-attribute-2} - -Added in: v1.26 - -- `name`# -- `options` <`LocatorAssertionsToHaveAttributeOptions?`> - - `Timeout`# -- returns:# - -Ensures the [Locator] points to an element with given attribute. The method will assert attribute presence. - -```csharp -var locator = Page.Locator("input"); -await Expect(locator).ToHaveAttributeAsync("disabled"); -await Expect(locator).Not.ToHaveAttributeAsync("open"); -``` - ## Expect(Locator).ToHaveClassAsync(expected, options) {#locator-assertions-to-have-class} Added in: v1.20 diff --git a/java/docs/release-notes.mdx b/java/docs/release-notes.mdx index f65509ddc8327..0a204022f539f 100644 --- a/java/docs/release-notes.mdx +++ b/java/docs/release-notes.mdx @@ -4,27 +4,6 @@ title: "Release notes" toc_max_heading_level: 2 --- -## Version 1.26 - -### Assertions -- [assertThat(locator).hasAttribute(name[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-2) can now be used for asserting attribute existence. -- New option `enabled` for [assertThat(locator).isEnabled([options])](/test-assertions.mdx#locator-assertions-to-be-enabled). -- [assertThat(locator).hasText(expected[, options])](/test-assertions.mdx#locator-assertions-to-have-text) now pierces open shadow roots. -- New option `editable` for [assertThat(locator).isEditable([options])](/test-assertions.mdx#locator-assertions-to-be-editable). -- New option `visible` for [assertThat(locator).isVisible([options])](/test-assertions.mdx#locator-assertions-to-be-visible). - -### Other highlights -- New option `setMaxRedirects` for [APIRequestContext.get(url[, options])](/api/class-apirequestcontext.mdx#api-request-context-get) and others to limit redirect count. -- Docker images are now using OpenJDK 17. - -### Behavior Change - -A bunch of Playwright APIs already support the `setWaitUntil(WaitUntilState.DOMCONTENTLOADED)` option. For example: - -Prior to 1.26, this would wait for all iframes to fire the `DOMContentLoaded` event. - -To align with web specification, the `WaitUntilState.DOMCONTENTLOADED` value only waits for the target frame to fire the `'DOMContentLoaded'` event. Use `setWaitUntil(WaitUntilState.LOAD)` to wait for all iframes. - ## Version 1.25 ### New APIs & changes diff --git a/java/docs/test-assertions.mdx b/java/docs/test-assertions.mdx index 776f11ca2a7e8..a4cb160896cf1 100644 --- a/java/docs/test-assertions.mdx +++ b/java/docs/test-assertions.mdx @@ -37,8 +37,7 @@ By default, the timeout for assertions is set to 5 seconds. - [assertThat(locator).isHidden([options])](/test-assertions.mdx#locator-assertions-to-be-hidden) - [assertThat(locator).isVisible([options])](/test-assertions.mdx#locator-assertions-to-be-visible) - [assertThat(locator).containsText(expected[, options])](/test-assertions.mdx#locator-assertions-to-contain-text) -- [assertThat(locator).hasAttribute(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-1) -- [assertThat(locator).hasAttribute(name[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-2) +- [assertThat(locator).hasAttribute(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute) - [assertThat(locator).hasClass(expected[, options])](/test-assertions.mdx#locator-assertions-to-have-class) - [assertThat(locator).hasCount(count[, options])](/test-assertions.mdx#locator-assertions-to-have-count) - [assertThat(locator).hasCSS(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-css) @@ -231,38 +230,22 @@ assertThat(page.locator("ul > li")).containsText(new String[] {"Some 33"}); assertThat(page.locator("ul")).containsText(new String[] {"Text 3"}); ``` -## assertThat(locator).hasAttribute(name, value[, options]) {#locator-assertions-to-have-attribute-1} +## assertThat(locator).hasAttribute(name, value[, options]) {#locator-assertions-to-have-attribute} -Added in: v1.18 +Added in: v1.20 -- `name`# -- `value`# +- `name`# +- `value`# - `options` <`LocatorAssertions.HasAttributeOptions`> - - `setTimeout`# -- returns:# + - `setTimeout`# +- returns:# -Ensures the [Locator] points to an element with given attribute value. +Ensures the [Locator] points to an element with given attribute. ```java assertThat(page.locator("input")).hasAttribute("type", "text"); ``` -## assertThat(locator).hasAttribute(name[, options]) {#locator-assertions-to-have-attribute-2} - -Added in: v1.26 - -- `name`# -- `options` <`LocatorAssertions.HasAttributeOptions`> - - `setTimeout`# -- returns:# - -Ensures the [Locator] points to an element with given attribute. The method will assert attribute presence. - -```java -assertThat(page.locator("input")).hasAttribute("disabled"); -assertThat(page.locator("input")).not().hasAttribute("open"); -``` - ## assertThat(locator).hasClass(expected[, options]) {#locator-assertions-to-have-class} Added in: v1.20 diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index 607c01788a64b..cec9bd3e9fc4f 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -17,7 +17,6 @@ With this integration, only **browser binaries** are running inside a Docker con Read more in [our documentation](./docker#experimental-playwright-test-docker-integration). ### Assertions -- [expect(locator).toHaveAttribute(name[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-2) can now be used for asserting attribute existence. - New option `enabled` for [expect(locator).toBeEnabled([options])](/test-assertions.mdx#locator-assertions-to-be-enabled). - [expect(locator).toHaveText(expected[, options])](/test-assertions.mdx#locator-assertions-to-have-text) now pierces open shadow roots. - New option `editable` for [expect(locator).toBeEditable([options])](/test-assertions.mdx#locator-assertions-to-be-editable). diff --git a/nodejs/docs/test-assertions.mdx b/nodejs/docs/test-assertions.mdx index af8147241372b..f4a4c5b18c44b 100644 --- a/nodejs/docs/test-assertions.mdx +++ b/nodejs/docs/test-assertions.mdx @@ -127,8 +127,7 @@ await expect.poll(async () => { - [expect(locator).toBeHidden([options])](/test-assertions.mdx#locator-assertions-to-be-hidden) - [expect(locator).toBeVisible([options])](/test-assertions.mdx#locator-assertions-to-be-visible) - [expect(locator).toContainText(expected[, options])](/test-assertions.mdx#locator-assertions-to-contain-text) -- [expect(locator).toHaveAttribute(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-1) -- [expect(locator).toHaveAttribute(name[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute-2) +- [expect(locator).toHaveAttribute(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-attribute) - [expect(locator).toHaveClass(expected[, options])](/test-assertions.mdx#locator-assertions-to-have-class) - [expect(locator).toHaveCount(count[, options])](/test-assertions.mdx#locator-assertions-to-have-count) - [expect(locator).toHaveCSS(name, value[, options])](/test-assertions.mdx#locator-assertions-to-have-css) @@ -337,42 +336,23 @@ await expect(page.locator('ul > li')).toContainText(['Some 33']); await expect(page.locator('ul')).toContainText(['Text 3']); ``` -## expect(locator).toHaveAttribute(name, value[, options]) {#locator-assertions-to-have-attribute-1} +## expect(locator).toHaveAttribute(name, value[, options]) {#locator-assertions-to-have-attribute} -Added in: v1.18 +Added in: v1.20 -- `name`# -- `value`# +- `name`# +- `value`# - `options?` <[Object]> - - `timeout?`# -- returns:# + - `timeout?`# +- returns:# -Ensures the [Locator] points to an element with given attribute value. +Ensures the [Locator] points to an element with given attribute. ```js const locator = page.locator('input'); -// Assert attribute with given value. await expect(locator).toHaveAttribute('type', 'text'); ``` -## expect(locator).toHaveAttribute(name[, options]) {#locator-assertions-to-have-attribute-2} - -Added in: v1.26 - -- `name`# -- `options?` <[Object]> - - `timeout?`# -- returns:# - -Ensures the [Locator] points to an element with given attribute. The method will assert attribute presence. - -```js -const locator = page.locator('input'); -// Assert attribute existence. -await expect(locator).toHaveAttribute('disabled'); -await expect(locator).not.toHaveAttribute('open'); -``` - ## expect(locator).toHaveClass(expected[, options]) {#locator-assertions-to-have-class} Added in: v1.20 diff --git a/nodejs/docs/test-components.mdx b/nodejs/docs/test-components.mdx index 0750b35b6cf7e..95606475e9a68 100644 --- a/nodejs/docs/test-components.mdx +++ b/nodejs/docs/test-components.mdx @@ -7,13 +7,6 @@ import TabItem from '@theme/TabItem'; Playwright Test can now test your components. -- [Example](#example) -- [How to get started](#how-to-get-started) -- [Hooks](#hooks) -- [Under the hood](#under-the-hood) -- [Known issues and limitations](#known-issues-and-limitations) -- [Planned work](#planned-work) -
@@ -50,16 +43,26 @@ Adding Playwright Test to an existing React, Vue or Svelte project is easy. Belo ### Step 1: Install Playwright Test for components for your respective framework -```sh + + + + +```bash npm init playwright@latest -- --ct ``` -or with Yarn: + -```sh + + +```bash yarn create playwright --ct ``` + + + + This step creates several files in your workspace: #### `playwright/index.html` @@ -77,13 +80,17 @@ This file defines an html file that will be used to render components during tes #### `playwright/index.ts` -You can include stylesheets, apply theme and inject code into the page where component is mounted using this script. It can be either `.js` or `.ts` file. +You can include stylesheets, apply theme and inject code into the page where component is mounted using this script. It can be either a `.js` or `.ts` file. ```js // Apply theme here, add anything your component needs at runtime here. ``` -### Step 2. Create a test file `src/App.spec.tsx` +### Step 2. Create a test file `src/App.spec.{ts,tsx}` + + + + ```js import { test, expect } from '@playwright/experimental-ct-react'; @@ -97,8 +104,52 @@ test('should work', async ({ mount }) => { }); ``` + + + + +```js +import { test, expect } from '@playwright/experimental-ct-vue'; +import App from './App.vue'; + +test.use({ viewport: { width: 500, height: 500 } }); + +test('should work', async ({ mount }) => { + const component = await mount(); + await expect(component).toContainText('Vite + Vue'); +}); +``` + +If using TypeScript and Vue make sure to add a `vue.d.ts` file to your project: + +```ts +declare module '*.vue'; +``` + + + + + +```js +import { test, expect } from '@playwright/experimental-ct-svelte'; +import App from './App.svelte'; + +test.use({ viewport: { width: 500, height: 500 } }); + +test('should work', async ({ mount }) => { + const component = await mount(App); + await expect(component).toContainText('Vite + Svelte'); +}); +``` + + + + + ### Step 3. Run the tests +You can run tests using the [VS Code extension](./getting-started-vscode.mdx) or the command line. + ```sh npm run test-ct ``` diff --git a/python/docs/release-notes.mdx b/python/docs/release-notes.mdx index 161852e6c03f1..8e38a3adc754e 100644 --- a/python/docs/release-notes.mdx +++ b/python/docs/release-notes.mdx @@ -4,31 +4,6 @@ title: "Release notes" toc_max_heading_level: 2 --- -## Version 1.26 - -### Assertions -- [expect(locator).to_have_attribute(name, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute-2) can now be used for asserting attribute existence. -- New option `enabled` for [expect(locator).to_be_enabled(**kwargs)](/test-assertions.mdx#locator-assertions-to-be-enabled). -- [expect(locator).to_have_text(expected, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-text) now pierces open shadow roots. -- New option `editable` for [expect(locator).to_be_editable(**kwargs)](/test-assertions.mdx#locator-assertions-to-be-editable). -- New option `visible` for [expect(locator).to_be_visible(**kwargs)](/test-assertions.mdx#locator-assertions-to-be-visible). - -### Other highlights -- New option `max_redirects` for [api_request_context.get(url, **kwargs)](/api/class-apirequestcontext.mdx#api-request-context-get) and others to limit redirect count. -- Python 3.11 is now supported. - -### Behavior Change - -A bunch of Playwright APIs already support the `wait_until: "domcontentloaded"` option. For example: - -```py -page.goto("https://playwright.dev", wait_until="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 `wait_until="load"` to wait for all iframes. - ## Version 1.25 ### Announcements diff --git a/python/docs/test-assertions.mdx b/python/docs/test-assertions.mdx index afc7c824116e5..23f69819552aa 100644 --- a/python/docs/test-assertions.mdx +++ b/python/docs/test-assertions.mdx @@ -55,8 +55,7 @@ By default, the timeout for assertions is set to 5 seconds. - [expect(locator).not_to_be_hidden(**kwargs)](/test-assertions.mdx#locator-assertions-not-to-be-hidden) - [expect(locator).not_to_be_visible(**kwargs)](/test-assertions.mdx#locator-assertions-not-to-be-visible) - [expect(locator).not_to_contain_text(expected, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-contain-text) -- [expect(locator).not_to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-attribute-1) -- [expect(locator).not_to_have_attribute(name, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-attribute-2) +- [expect(locator).not_to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-attribute) - [expect(locator).not_to_have_class(expected, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-class) - [expect(locator).not_to_have_count(count, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-count) - [expect(locator).not_to_have_css(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-not-to-have-css) @@ -74,8 +73,7 @@ By default, the timeout for assertions is set to 5 seconds. - [expect(locator).to_be_hidden(**kwargs)](/test-assertions.mdx#locator-assertions-to-be-hidden) - [expect(locator).to_be_visible(**kwargs)](/test-assertions.mdx#locator-assertions-to-be-visible) - [expect(locator).to_contain_text(expected, **kwargs)](/test-assertions.mdx#locator-assertions-to-contain-text) -- [expect(locator).to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute-1) -- [expect(locator).to_have_attribute(name, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute-2) +- [expect(locator).to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute) - [expect(locator).to_have_class(expected, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-class) - [expect(locator).to_have_count(count, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-count) - [expect(locator).to_have_css(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-css) @@ -178,26 +176,16 @@ The opposite of [expect(locator).to_be_visible(**kwargs)](/test-assertions.mdx#l The opposite of [expect(locator).to_contain_text(expected, **kwargs)](/test-assertions.mdx#locator-assertions-to-contain-text). -## expect(locator).not_to_have_attribute(name, value, **kwargs) {#locator-assertions-not-to-have-attribute-1} +## expect(locator).not_to_have_attribute(name, value, **kwargs) {#locator-assertions-not-to-have-attribute} -Added in: v1.18 - -- `name`# -- `value`# -- `timeout`# -- returns:# - -The opposite of [expect(locator).to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute-1). - -## expect(locator).not_to_have_attribute(name, **kwargs) {#locator-assertions-not-to-have-attribute-2} - -Added in: v1.26 +Added in: v1.20 -- `name`# -- `timeout`# -- returns:# +- `name`# +- `value`# +- `timeout`# +- returns:# -The opposite of [expect(locator).to_have_attribute(name, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute-2). +The opposite of [expect(locator).to_have_attribute(name, value, **kwargs)](/test-assertions.mdx#locator-assertions-to-have-attribute). ## expect(locator).not_to_have_class(expected, **kwargs) {#locator-assertions-not-to-have-class} @@ -711,16 +699,16 @@ await expect(page.locator("ul")).to_contain_text(["Text 3"]) -## expect(locator).to_have_attribute(name, value, **kwargs) {#locator-assertions-to-have-attribute-1} +## expect(locator).to_have_attribute(name, value, **kwargs) {#locator-assertions-to-have-attribute} -Added in: v1.18 +Added in: v1.20 -- `name`# -- `value`# -- `timeout`# -- returns:# +- `name`# +- `value`# +- `timeout`# +- returns:# -Ensures the [Locator] points to an element with given attribute value. +Ensures the [Locator] points to an element with given attribute. -## expect(locator).to_have_attribute(name, **kwargs) {#locator-assertions-to-have-attribute-2} - -Added in: v1.26 - -- `name`# -- `timeout`# -- returns:# - -Ensures the [Locator] points to an element with given attribute. The method will assert attribute presence. - - - - -```py -from playwright.sync_api import expect - -locator = page.locator("input") -expect(locator).to_have_attribute("disabled") -expect(locator).not_to_have_attribute("open") -``` - - - - -```py -from playwright.async_api import expect - -locator = page.locator("input") -await expect(locator).to_have_attribute("disabled") -await expect(locator).not_to_have_attribute("open") -``` - - - - ## expect(locator).to_have_class(expected, **kwargs) {#locator-assertions-to-have-class} Added in: v1.20