diff --git a/dotnet/docs/api/class-request.mdx b/dotnet/docs/api/class-request.mdx index 28cfc5804e9..edb81d78dfe 100644 --- a/dotnet/docs/api/class-request.mdx +++ b/dotnet/docs/api/class-request.mdx @@ -43,57 +43,6 @@ await Request.AllHeadersAsync(); --- -### BodyAsync {#request-body} - -Added in: v1.57request.BodyAsync - -The request body, if present. - -**Usage** - -```csharp -await Request.BodyAsync(); -``` - -**Returns** -- [string]?# - ---- - -### BodyBufferAsync {#request-body-buffer} - -Added in: v1.57request.BodyBufferAsync - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```csharp -await Request.BodyBufferAsync(); -``` - -**Returns** -- [byte][]?# - ---- - -### BodyJSONAsync {#request-body-json} - -Added in: v1.57request.BodyJSONAsync - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```csharp -await Request.BodyJSONAsync(); -``` - -**Returns** -- [JsonElement]?# - ---- - ### Failure {#request-failure} Added before v1.9request.Failure @@ -239,6 +188,59 @@ Request.Method --- +### PostData {#request-post-data} + +Added before v1.9request.PostData + +Request's post body, if any. + +**Usage** + +```csharp +Request.PostData +``` + +**Returns** +- [string]?# + +--- + +### PostDataBuffer {#request-post-data-buffer} + +Added before v1.9request.PostDataBuffer + +Request's post body in a binary form, if any. + +**Usage** + +```csharp +Request.PostDataBuffer +``` + +**Returns** +- [byte][]?# + +--- + +### PostDataJSON {#request-post-data-json} + +Added in: v1.12request.PostDataJSON + +Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. + +When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. Otherwise it will be parsed as JSON. + +**Usage** + +```csharp +Request.PostDataJSON +``` + +**Returns** +- [JsonElement]?# + +--- + ### RedirectedFrom {#request-redirected-from} Added before v1.9request.RedirectedFrom @@ -413,80 +415,6 @@ Request.Url **Returns** - [string]# ---- - -## Deprecated - -### PostData {#request-post-data} - -Added before v1.9request.PostData - -:::warning[Discouraged] - -Use [Request.BodyAsync()](/api/class-request.mdx#request-body) instead. - -::: - - -The request body, if present. - -**Usage** - -```csharp -Request.PostData -``` - -**Returns** -- [string]?# - ---- - -### PostDataBuffer {#request-post-data-buffer} - -Added before v1.9request.PostDataBuffer - -:::warning[Discouraged] - -Use [Request.BodyBufferAsync()](/api/class-request.mdx#request-body-buffer) instead. - -::: - - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```csharp -Request.PostDataBuffer -``` - -**Returns** -- [byte][]?# - ---- - -### PostDataJSON {#request-post-data-json} - -Added in: v1.12request.PostDataJSON - -:::warning[Discouraged] - -Use [Request.BodyJSONAsync()](/api/class-request.mdx#request-body-json) instead. - -::: - - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```csharp -Request.PostDataJSON -``` - -**Returns** -- [JsonElement]?# - [APIRequest]: /api/class-apirequest.mdx "APIRequest" [APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext" diff --git a/images/cft-logo-change.png b/images/cft-logo-change.png new file mode 100644 index 00000000000..89c5695e29f Binary files /dev/null and b/images/cft-logo-change.png differ diff --git a/images/speedboard.png b/images/speedboard.png new file mode 100644 index 00000000000..e6fa26ab611 Binary files /dev/null and b/images/speedboard.png differ diff --git a/java/docs/api/class-request.mdx b/java/docs/api/class-request.mdx index 4f9609de779..11d2f87c357 100644 --- a/java/docs/api/class-request.mdx +++ b/java/docs/api/class-request.mdx @@ -43,40 +43,6 @@ Request.allHeaders(); --- -### body {#request-body} - -Added in: v1.57request.body - -The request body, if present. - -**Usage** - -```java -Request.body(); -``` - -**Returns** -- [null] | [String]# - ---- - -### bodyBuffer {#request-body-buffer} - -Added in: v1.57request.bodyBuffer - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```java -Request.bodyBuffer(); -``` - -**Returns** -- [null] | [byte[]]# - ---- - ### failure {#request-failure} Added before v1.9request.failure @@ -221,6 +187,40 @@ Request.method(); --- +### postData {#request-post-data} + +Added before v1.9request.postData + +Request's post body, if any. + +**Usage** + +```java +Request.postData(); +``` + +**Returns** +- [null] | [String]# + +--- + +### postDataBuffer {#request-post-data-buffer} + +Added before v1.9request.postDataBuffer + +Request's post body in a binary form, if any. + +**Usage** + +```java +Request.postDataBuffer(); +``` + +**Returns** +- [null] | [byte[]]# + +--- + ### redirectedFrom {#request-redirected-from} Added before v1.9request.redirectedFrom @@ -395,56 +395,6 @@ Request.url(); **Returns** - [String]# ---- - -## Deprecated - -### postData {#request-post-data} - -Added before v1.9request.postData - -:::warning[Discouraged] - -Use [Request.body()](/api/class-request.mdx#request-body) instead. - -::: - - -The request body, if present. - -**Usage** - -```java -Request.postData(); -``` - -**Returns** -- [null] | [String]# - ---- - -### postDataBuffer {#request-post-data-buffer} - -Added before v1.9request.postDataBuffer - -:::warning[Discouraged] - -Use [Request.bodyBuffer()](/api/class-request.mdx#request-body-buffer) instead. - -::: - - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```java -Request.postDataBuffer(); -``` - -**Returns** -- [null] | [byte[]]# - [APIRequest]: /api/class-apirequest.mdx "APIRequest" [APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext" diff --git a/nodejs/docs/api/class-request.mdx b/nodejs/docs/api/class-request.mdx index ac7974787b1..18b9c4b6eb1 100644 --- a/nodejs/docs/api/class-request.mdx +++ b/nodejs/docs/api/class-request.mdx @@ -43,57 +43,6 @@ await request.allHeaders(); --- -### body {#request-body} - -Added in: v1.57request.body - -The request body, if present. - -**Usage** - -```js -await request.body(); -``` - -**Returns** -- [Promise]<[null] | [string]># - ---- - -### bodyBuffer {#request-body-buffer} - -Added in: v1.57request.bodyBuffer - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```js -await request.bodyBuffer(); -``` - -**Returns** -- [Promise]<[null] | [Buffer]># - ---- - -### bodyJSON {#request-body-json} - -Added in: v1.57request.bodyJSON - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```js -await request.bodyJSON(); -``` - -**Returns** -- [Promise]<[null] | [Serializable]># - ---- - ### failure {#request-failure} Added before v1.9request.failure @@ -250,6 +199,59 @@ request.method(); --- +### postData {#request-post-data} + +Added before v1.9request.postData + +Request's post body, if any. + +**Usage** + +```js +request.postData(); +``` + +**Returns** +- [null] | [string]# + +--- + +### postDataBuffer {#request-post-data-buffer} + +Added before v1.9request.postDataBuffer + +Request's post body in a binary form, if any. + +**Usage** + +```js +request.postDataBuffer(); +``` + +**Returns** +- [null] | [Buffer]# + +--- + +### postDataJSON {#request-post-data-json} + +Added before v1.9request.postDataJSON + +Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. + +When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. Otherwise it will be parsed as JSON. + +**Usage** + +```js +request.postDataJSON(); +``` + +**Returns** +- [null] | [Serializable]# + +--- + ### redirectedFrom {#request-redirected-from} Added before v1.9request.redirectedFrom @@ -446,80 +448,6 @@ request.url(); **Returns** - [string]# ---- - -## Deprecated - -### postData {#request-post-data} - -Added before v1.9request.postData - -:::warning[Discouraged] - -Use [request.body()](/api/class-request.mdx#request-body) instead. - -::: - - -The request body, if present. - -**Usage** - -```js -request.postData(); -``` - -**Returns** -- [null] | [string]# - ---- - -### postDataBuffer {#request-post-data-buffer} - -Added before v1.9request.postDataBuffer - -:::warning[Discouraged] - -Use [request.bodyBuffer()](/api/class-request.mdx#request-body-buffer) instead. - -::: - - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```js -request.postDataBuffer(); -``` - -**Returns** -- [null] | [Buffer]# - ---- - -### postDataJSON {#request-post-data-json} - -Added before v1.9request.postDataJSON - -:::warning[Discouraged] - -Use [request.bodyJSON()](/api/class-request.mdx#request-body-json) instead. - -::: - - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```js -request.postDataJSON(); -``` - -**Returns** -- [null] | [Serializable]# - [Android]: /api/class-android.mdx "Android" [AndroidDevice]: /api/class-androiddevice.mdx "AndroidDevice" diff --git a/nodejs/docs/api/class-testconfig.mdx b/nodejs/docs/api/class-testconfig.mdx index ed1e0069548..0b6c9d50459 100644 --- a/nodejs/docs/api/class-testconfig.mdx +++ b/nodejs/docs/api/class-testconfig.mdx @@ -1070,6 +1070,31 @@ export default defineConfig({ }); ``` +If your webserver runs on varying ports, use `wait` to capture the port: + +```js +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ + webServer: { + command: 'npm run start', + wait: { + stdout: '/Listening on port (?\\d+)/' + }, + }, +}); +``` + +```js +import { test, expect } from '@playwright/test'; + +test.use({ baseUrl: `http://localhost:${process.env.MY_SERVER_PORT ?? 3000}` }); + +test('homepage', async ({ page }) => { + await page.goto('/'); +}); +``` + **Type** - [Object] | [Array]<[Object]> - `command` [string] diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index 81c5b2ab384..663a61b8593 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -9,6 +9,75 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.57 + +### Speedboard + +In HTML reporter, there's a new tab we call "Speedboard": + +![Speedboard](../images/speedboard.png) + +It shows you all your executed tests sorted by slowness, and can help you understand where your test suite is taking longer than expected. Take a look at yours - maybe you'll find some tests that are spending a longer time waiting than they should! + +### Chrome for Testing + +Starting with this release, Playwright switches from Chromium, to using [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) builds. Both headed and headless browsers are subject to this. Your tests should still be passing after upgrading to Playwright 1.57. We're expecting no functional changes to come from this switch - the biggest change is the new icon and title in your toolbar: + +![new and old logo](../images/cft-logo-change.png) + +If you still see an unexpected behaviour change, please [file an issue](https://github.com/microsoft/playwright/issues/new). + +On Arm64 Linux, Playwright continues to use Chromium. + +### Waiting for webserver output + +[testConfig.webServer](/api/class-testconfig.mdx#test-config-web-server) added a `wait` field. Pass a regular expression, and Playwright will wait until the webserver logs match it. + +```js +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ + webServer: { + command: 'npm run start', + wait: { + stdout: '/Listening on port (?\\d+)/' + }, + }, +}); +``` + +If you include a named capture group into the expression, then Playwright will provide the capture group contents via environment variables: + +```js +import { test, expect } from '@playwright/test'; + +test.use({ baseUrl: `http://localhost:${process.env.MY_SERVER_PORT ?? 3000}` }); + +test('homepage', async ({ page }) => { + await page.goto('/'); +}); +``` + +This is not just useful for capturing varying ports of dev servers: You can also use it to wait for readiness of a service that doesn't expose an HTTP readiness check, but instead prints a readiness message to stdout or stderr. + +### Breaking Change + +After 3 years of being deprecated, we removed `Page#accessibility` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. + +### New APIs +- New property [testConfig.tag](/api/class-testconfig.mdx#test-config-tag) adds a tag to all tests in this run. This is useful when using [merge-reports](./test-sharding.mdx#merging-reports-from-multiple-shards). +- [worker.on('console')](/api/class-worker.mdx#worker-event-console) event is emitted when JavaScript within the worker calls one of console API methods, e.g. console.log or console.dir. [worker.waitForEvent()](/api/class-worker.mdx#worker-wait-for-event) can be used to wait for it. You can opt out of this using the `PLAYWRIGHT_DISABLE_SERVICE_WORKER_CONSOLE` environment variable. +- [locator.description()](/api/class-locator.mdx#locator-description) returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe), and `Locator.toString()` now uses the description when available. +- New option [steps](/api/class-locator.mdx#locator-click-option-steps) in [locator.click()](/api/class-locator.mdx#locator-click) and [locator.dragTo()](/api/class-locator.mdx#locator-drag-to) that configures the number of `mousemove` events emitted while moving the mouse pointer to the target element. +- Network requests issued by [Service Workers](./service-workers.mdx#network-events-and-routing) are now reported and can be routed through the [BrowserContext](./api/class-browsercontext.mdx), only in Chromium. You can opt out using the `PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK` environment variable. +- New methods [request.postData()](/api/class-request.mdx#request-post-data), [request.postDataBuffer()](/api/class-request.mdx#request-post-data-buffer) and [request.postDataJSON()](/api/class-request.mdx#request-post-data-json). +- Option [testConfig.webServer](/api/class-testconfig.mdx#test-config-web-server) added a `wait` field to check readiness based on stdout/stderr. + +### Browser Versions +- Chromium 143.0.7499.4 +- Mozilla Firefox 142.0.1 +- WebKit 26.0 + ## Version 1.56 diff --git a/python/docs/api/class-request.mdx b/python/docs/api/class-request.mdx index e14ac2ae291..6f047b19a30 100644 --- a/python/docs/api/class-request.mdx +++ b/python/docs/api/class-request.mdx @@ -43,57 +43,6 @@ request.all_headers() --- -### body {#request-body} - -Added in: v1.57request.body - -The request body, if present. - -**Usage** - -```python -request.body() -``` - -**Returns** -- [NoneType] | [str]# - ---- - -### body_buffer {#request-body-buffer} - -Added in: v1.57request.body_buffer - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```python -request.body_buffer() -``` - -**Returns** -- [NoneType] | [bytes]# - ---- - -### body_json {#request-body-json} - -Added in: v1.57request.body_json - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```python -request.body_json() -``` - -**Returns** -- [NoneType] | [Dict]# - ---- - ### header_value {#request-header-value} Added in: v1.15request.header_value @@ -284,6 +233,59 @@ request.method --- +### post_data {#request-post-data} + +Added before v1.9request.post_data + +Request's post body, if any. + +**Usage** + +```python +request.post_data +``` + +**Returns** +- [NoneType] | [str]# + +--- + +### post_data_buffer {#request-post-data-buffer} + +Added before v1.9request.post_data_buffer + +Request's post body in a binary form, if any. + +**Usage** + +```python +request.post_data_buffer +``` + +**Returns** +- [NoneType] | [bytes]# + +--- + +### post_data_json {#request-post-data-json} + +Added before v1.9request.post_data_json + +Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. + +When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. Otherwise it will be parsed as JSON. + +**Usage** + +```python +request.post_data_json +``` + +**Returns** +- [NoneType] | [Dict]# + +--- + ### redirected_from {#request-redirected-from} Added before v1.9request.redirected_from @@ -476,80 +478,6 @@ request.url **Returns** - [str]# ---- - -## Deprecated - -### post_data {#request-post-data} - -Added before v1.9request.post_data - -:::warning[Discouraged] - -Use [request.body()](/api/class-request.mdx#request-body) instead. - -::: - - -The request body, if present. - -**Usage** - -```python -request.post_data -``` - -**Returns** -- [NoneType] | [str]# - ---- - -### post_data_buffer {#request-post-data-buffer} - -Added before v1.9request.post_data_buffer - -:::warning[Discouraged] - -Use [request.body_buffer()](/api/class-request.mdx#request-body-buffer) instead. - -::: - - -The request body in a binary form. Returns null if the request has no body. - -**Usage** - -```python -request.post_data_buffer -``` - -**Returns** -- [NoneType] | [bytes]# - ---- - -### post_data_json {#request-post-data-json} - -Added before v1.9request.post_data_json - -:::warning[Discouraged] - -Use [request.body_json()](/api/class-request.mdx#request-body-json) instead. - -::: - - -Returns the request body as a parsed JSON object. If the request `Content-Type` is `application/x-www-form-urlencoded`, this method returns a key/value object parsed from the form data. Otherwise, it parses the body as JSON. - -**Usage** - -```python -request.post_data_json -``` - -**Returns** -- [NoneType] | [Dict]# - [APIRequest]: /api/class-apirequest.mdx "APIRequest" [APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext"