diff --git a/dotnet/versioned_docs/images/timeline.png b/dotnet/versioned_docs/images/timeline.png new file mode 100644 index 0000000000..4d1a12035c Binary files /dev/null and b/dotnet/versioned_docs/images/timeline.png differ diff --git a/dotnet/versioned_docs/version-stable/api/class-browsertype.mdx b/dotnet/versioned_docs/version-stable/api/class-browsertype.mdx index f6f48e227a..c5c1a16114 100644 --- a/dotnet/versioned_docs/version-stable/api/class-browsertype.mdx +++ b/dotnet/versioned_docs/version-stable/api/class-browsertype.mdx @@ -116,6 +116,9 @@ var page = defaultContext.Pages[0]; - `Headers` [IDictionary]?<[string], [string]> *(optional)* Added in: v1.11# Additional HTTP headers to be sent with connect request. Optional. + - `IsLocal` [bool]? *(optional)* Added in: v1.58# + + Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon the file system being the same between Playwright and the Browser. - `SlowMo` [float]? *(optional)* Added in: v1.11# Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. @@ -187,14 +190,6 @@ var browser = await playwright.Chromium.LaunchAsync(new() { - `ChromiumSandbox` [bool]? *(optional)*# Enable Chromium sandboxing. Defaults to `false`. - - `Devtools` [bool]? *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [Headless](/api/class-browsertype.mdx#browser-type-launch-option-headless) option will be set `false`. - `DownloadsPath` [string]? *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -220,7 +215,7 @@ var browser = await playwright.Chromium.LaunchAsync(new() { Close the browser process on SIGTERM. Defaults to `true`. - `Headless` [bool]? *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [Devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `IgnoreAllDefaultArgs` [bool]? *(optional)* Added in: v1.9# If `true`, Playwright does not pass its own configurations args and only uses the ones from [Args](/api/class-browsertype.mdx#browser-type-launch-option-args). Dangerous option; use with care. Defaults to `false`. @@ -364,14 +359,6 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options); - `DeviceScaleFactor` [float]? *(optional)*# Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about [emulating devices with device scale factor](../emulation.mdx#devices). - - `Devtools` [bool]? *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [Headless](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-headless) option will be set `false`. - `DownloadsPath` [string]? *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -416,7 +403,7 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options); Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - `Headless` [bool]? *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [Devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `HttpCredentials` HttpCredentials? *(optional)*# - `Username` [string] diff --git a/dotnet/versioned_docs/version-stable/api/class-locator.mdx b/dotnet/versioned_docs/version-stable/api/class-locator.mdx index 3126ed6cdb..731b0c27c3 100644 --- a/dotnet/versioned_docs/version-stable/api/class-locator.mdx +++ b/dotnet/versioned_docs/version-stable/api/class-locator.mdx @@ -555,7 +555,7 @@ await button.ClickAsync(); Added in: v1.57locator.Description -Returns locator description previously set with [Locator.Describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the description when available. +Returns locator description previously set with [Locator.Describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. **Usage** diff --git a/dotnet/versioned_docs/version-stable/api/class-locatorassertions.mdx b/dotnet/versioned_docs/version-stable/api/class-locatorassertions.mdx index 19d688f04f..a36956dd63 100644 --- a/dotnet/versioned_docs/version-stable/api/class-locatorassertions.mdx +++ b/dotnet/versioned_docs/version-stable/api/class-locatorassertions.mdx @@ -384,7 +384,7 @@ Let's see how we can use the assertion: ```csharp // ✓ Contains the right items in the right order -await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 1", "Text 3", "Text 4"}); +await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 1", "Text 3"}); // ✖ Wrong order await Expect(Page.Locator("ul > li")).ToContainTextAsync(new string[] {"Text 3", "Text 2"}); diff --git a/dotnet/versioned_docs/version-stable/api/class-route.mdx b/dotnet/versioned_docs/version-stable/api/class-route.mdx index 4c9217f86e..2150752d31 100644 --- a/dotnet/versioned_docs/version-stable/api/class-route.mdx +++ b/dotnet/versioned_docs/version-stable/api/class-route.mdx @@ -95,7 +95,9 @@ The [Headers](/api/class-route.mdx#route-continue-option-headers) option applies :::warning -The `Cookie` header cannot be overridden using this method. If a value is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use [BrowserContext.AddCookiesAsync()](/api/class-browsercontext.mdx#browser-context-add-cookies). +Some request headers are **forbidden** and cannot be overridden (for example, `Cookie`, `Host`, `Content-Length` and others, see [this MDN page](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header) for full list). If an override is provided for a forbidden header, it will be ignored and the original request header will be used. + +To set custom cookies, use [BrowserContext.AddCookiesAsync()](/api/class-browsercontext.mdx#browser-context-add-cookies). ::: --- diff --git a/dotnet/versioned_docs/version-stable/docker.mdx b/dotnet/versioned_docs/version-stable/docker.mdx index 90dd50511a..02f1989952 100644 --- a/dotnet/versioned_docs/version-stable/docker.mdx +++ b/dotnet/versioned_docs/version-stable/docker.mdx @@ -109,6 +109,24 @@ This makes `hostmachine` point to the host's localhost. Your tests should use `h When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container. ::: +### Connecting using noVNC and GitHub Codespaces + +For Docker and GitHub Codespaces environments, you can view and generate tests using the `noVNC` viewer built into the Docker image. In order for the VNC webviewer to be accessible outside of the container, you can enable the `desktop-lite` feature and specify the `webPort` in your `.devcontainer/devcontainer.json` file: + +```json +{ + "image": "mcr.microsoft.com/playwright:v1.57.0", + "forwardPorts": [6080], + "features": { + "desktop-lite": { + "webPort": "6080" + } + } +} +``` + +Once this is enabled you can open the port specified in a new browser tab and you will have access to the `noVNC` web viewer. This will enable you to record tests, pick selectors, and use codegen directly on your container. + ## Image tags See [all available image tags]. diff --git a/dotnet/versioned_docs/version-stable/locators.mdx b/dotnet/versioned_docs/version-stable/locators.mdx index 80febbb216..29b02ac6fe 100644 --- a/dotnet/versioned_docs/version-stable/locators.mdx +++ b/dotnet/versioned_docs/version-stable/locators.mdx @@ -477,7 +477,7 @@ Alternatively, filter by **not having** text: ```csharp // 5 in-stock items -await Expect(Page.getByRole(AriaRole.Listitem).Filter(new() { HasNotText = "Out of stock" })) +await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasNotText = "Out of stock" })) .ToHaveCountAsync(5); ``` diff --git a/java/versioned_docs/images/timeline.png b/java/versioned_docs/images/timeline.png new file mode 100644 index 0000000000..4d1a12035c Binary files /dev/null and b/java/versioned_docs/images/timeline.png differ diff --git a/java/versioned_docs/version-stable/api/class-browsertype.mdx b/java/versioned_docs/version-stable/api/class-browsertype.mdx index 29864e9182..08bcceedce 100644 --- a/java/versioned_docs/version-stable/api/class-browsertype.mdx +++ b/java/versioned_docs/version-stable/api/class-browsertype.mdx @@ -115,6 +115,9 @@ Page page = defaultContext.pages().get(0); - `setHeaders` [Map]<[String], [String]> *(optional)* Added in: v1.11# Additional HTTP headers to be sent with connect request. Optional. + - `setIsLocal` [boolean] *(optional)* Added in: v1.58# + + Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon the file system being the same between Playwright and the Browser. - `setSlowMo` [double] *(optional)* Added in: v1.11# Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. @@ -186,14 +189,6 @@ Browser browser = chromium.launch(new BrowserType.LaunchOptions() - `setChromiumSandbox` [boolean] *(optional)*# Enable Chromium sandboxing. Defaults to `false`. - - `setDevtools` [boolean] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [setHeadless](/api/class-browsertype.mdx#browser-type-launch-option-headless) option will be set `false`. - `setDownloadsPath` [Path] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -219,7 +214,7 @@ Browser browser = chromium.launch(new BrowserType.LaunchOptions() Close the browser process on SIGTERM. Defaults to `true`. - `setHeadless` [boolean] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [setDevtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `setIgnoreAllDefaultArgs` [boolean] *(optional)* Added in: v1.9# If `true`, Playwright does not pass its own configurations args and only uses the ones from [setArgs](/api/class-browsertype.mdx#browser-type-launch-option-args). Dangerous option; use with care. Defaults to `false`. @@ -364,14 +359,6 @@ BrowserType.launchPersistentContext(userDataDir, options); - `setDeviceScaleFactor` [double] *(optional)*# Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about [emulating devices with device scale factor](../emulation.mdx#devices). - - `setDevtools` [boolean] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [setHeadless](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-headless) option will be set `false`. - `setDownloadsPath` [Path] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -416,7 +403,7 @@ BrowserType.launchPersistentContext(userDataDir, options); Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - `setHeadless` [boolean] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [setDevtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `setHttpCredentials` HttpCredentials *(optional)*# - `setUsername` [String] diff --git a/java/versioned_docs/version-stable/api/class-locator.mdx b/java/versioned_docs/version-stable/api/class-locator.mdx index 580a413b7e..fd9468f973 100644 --- a/java/versioned_docs/version-stable/api/class-locator.mdx +++ b/java/versioned_docs/version-stable/api/class-locator.mdx @@ -556,7 +556,7 @@ button.click(); Added in: v1.57locator.description -Returns locator description previously set with [Locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the description when available. +Returns locator description previously set with [Locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. **Usage** diff --git a/java/versioned_docs/version-stable/api/class-locatorassertions.mdx b/java/versioned_docs/version-stable/api/class-locatorassertions.mdx index 53e31f6e3c..3ecb640b41 100644 --- a/java/versioned_docs/version-stable/api/class-locatorassertions.mdx +++ b/java/versioned_docs/version-stable/api/class-locatorassertions.mdx @@ -107,7 +107,7 @@ Let's see how we can use the assertion: ```java // ✓ Contains the right items in the right order -assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"}); +assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"}); // ✖ Wrong order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"}); diff --git a/java/versioned_docs/version-stable/api/class-route.mdx b/java/versioned_docs/version-stable/api/class-route.mdx index a50646b90a..db2a6c9a3a 100644 --- a/java/versioned_docs/version-stable/api/class-route.mdx +++ b/java/versioned_docs/version-stable/api/class-route.mdx @@ -307,7 +307,9 @@ The [setHeaders](/api/class-route.mdx#route-continue-option-headers) option appl :::warning -The `Cookie` header cannot be overridden using this method. If a value is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use [BrowserContext.addCookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). +Some request headers are **forbidden** and cannot be overridden (for example, `Cookie`, `Host`, `Content-Length` and others, see [this MDN page](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header) for full list). If an override is provided for a forbidden header, it will be ignored and the original request header will be used. + +To set custom cookies, use [BrowserContext.addCookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). ::: diff --git a/java/versioned_docs/version-stable/clock.mdx b/java/versioned_docs/version-stable/clock.mdx index 64655dd6fb..2d390c25cc 100644 --- a/java/versioned_docs/version-stable/clock.mdx +++ b/java/versioned_docs/version-stable/clock.mdx @@ -59,7 +59,7 @@ Often you only need to fake `Date.now` while keeping the timers going. That way ``` ```java -SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss"); +SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); page.clock().setFixedTime(format.parse("2024-02-02T10:00:00")); page.navigate("http://localhost:3333"); Locator locator = page.getByTestId("current-time"); @@ -87,7 +87,7 @@ Sometimes your timers depend on `Date.now` and are confused when the `Date.now` ```java // Initialize clock with some time before the test time and let the page load // naturally. `Date.now` will progress as the timers fire. -SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss"); +SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); page.clock().install(new Clock.InstallOptions().setTime(format.parse("2024-02-02T08:00:00"))); page.navigate("http://localhost:3333"); Locator locator = page.getByTestId("current-time"); @@ -162,7 +162,7 @@ In rare cases, you may want to tick through time manually, firing all timers and ``` ```java -SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss"); +SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // Initialize clock with a specific time, let the page load naturally. page.clock().install(new Clock.InstallOptions() .setTime(format.parse("2024-02-02T08:00:00"))); diff --git a/java/versioned_docs/version-stable/docker.mdx b/java/versioned_docs/version-stable/docker.mdx index 8319cb65c4..7473b189fb 100644 --- a/java/versioned_docs/version-stable/docker.mdx +++ b/java/versioned_docs/version-stable/docker.mdx @@ -117,6 +117,24 @@ This makes `hostmachine` point to the host's localhost. Your tests should use `h When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container. ::: +### Connecting using noVNC and GitHub Codespaces + +For Docker and GitHub Codespaces environments, you can view and generate tests using the `noVNC` viewer built into the Docker image. In order for the VNC webviewer to be accessible outside of the container, you can enable the `desktop-lite` feature and specify the `webPort` in your `.devcontainer/devcontainer.json` file: + +```json +{ + "image": "mcr.microsoft.com/playwright:v1.57.0", + "forwardPorts": [6080], + "features": { + "desktop-lite": { + "webPort": "6080" + } + } +} +``` + +Once this is enabled you can open the port specified in a new browser tab and you will have access to the `noVNC` web viewer. This will enable you to record tests, pick selectors, and use codegen directly on your container. + ## Image tags See [all available image tags]. diff --git a/java/versioned_docs/version-stable/input.mdx b/java/versioned_docs/version-stable/input.mdx index 1527d1df3d..7d8c57d7a9 100644 --- a/java/versioned_docs/version-stable/input.mdx +++ b/java/versioned_docs/version-stable/input.mdx @@ -22,7 +22,7 @@ page.getByRole(AriaRole.TEXTBOX).fill("Peter"); page.getByLabel("Birth date").fill("2020-02-02"); // Time input -page.getByLabel("Appointment time").fill("13-15"); +page.getByLabel("Appointment time").fill("13:15"); // Local datetime input page.getByLabel("Local time").fill("2020-03-02T05:15"); @@ -37,7 +37,7 @@ Using [Locator.setChecked()](/api/class-locator.mdx#locator-set-checked) is the page.getByLabel("I agree to the terms above").check(); // Assert the checked state -assertTrue(page.getByLabel("Subscribe to newsletter")).isChecked(); +assertThat(page.getByLabel("Subscribe to newsletter")).isChecked(); // Select the radio button page.getByLabel("XL").check(); diff --git a/java/versioned_docs/version-stable/intro.mdx b/java/versioned_docs/version-stable/intro.mdx index c987e6efcd..9635207443 100644 --- a/java/versioned_docs/version-stable/intro.mdx +++ b/java/versioned_docs/version-stable/intro.mdx @@ -82,7 +82,7 @@ public class App { -With the Example.java and pom.xml above, compile and execute your new program as follows: +With the App.java and pom.xml above, compile and execute your new program as follows: ```bash mvn compile exec:java -D exec.mainClass="org.example.App" diff --git a/java/versioned_docs/version-stable/locators.mdx b/java/versioned_docs/version-stable/locators.mdx index cbb508e2a7..904a7f0da0 100644 --- a/java/versioned_docs/version-stable/locators.mdx +++ b/java/versioned_docs/version-stable/locators.mdx @@ -459,7 +459,7 @@ Locators can be filtered by text with the [Locator.filter()](/api/class-locator. page.getByRole(AriaRole.LISTITEM) .filter(new Locator.FilterOptions().setHasText("Product 2")) .getByRole(AriaRole.BUTTON, - new Page.GetByRoleOptions().setName("Add to cart")) + new Locator.GetByRoleOptions().setName("Add to cart")) .click(); ``` @@ -470,7 +470,7 @@ page.getByRole(AriaRole.LISTITEM) .filter(new Locator.FilterOptions() .setHasText(Pattern.compile("Product 2"))) .getByRole(AriaRole.BUTTON, - new Page.GetByRoleOptions().setName("Add to cart")) + new Locator.GetByRoleOptions().setName("Add to cart")) .click(); ``` @@ -520,10 +520,10 @@ Locators support an option to only select elements that have or have not a desce ```java page.getByRole(AriaRole.LISTITEM) .filter(new Locator.FilterOptions() - .setHas(page.GetByRole(AriaRole.HEADING, new Page.GetByRoleOptions() + .setHas(page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions() .setName("Product 2")))) .getByRole(AriaRole.BUTTON, - new Page.GetByRoleOptions().setName("Add to cart")) + new Locator.GetByRoleOptions().setName("Add to cart")) .click(); ``` @@ -533,7 +533,7 @@ We can also assert the product card to make sure there is only one: assertThat(page .getByRole(AriaRole.LISTITEM) .filter(new Locator.FilterOptions() - .setHas(page.GetByRole(AriaRole.HEADING, + .setHas(page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("Product 2"))))) .hasCount(1); ``` @@ -545,9 +545,9 @@ The filtering locator **must be relative** to the original locator and is querie assertThat(page .getByRole(AriaRole.LISTITEM) .filter(new Locator.FilterOptions() - .setHas(page.GetByRole(AriaRole.LIST) - .GetByRole(AriaRole.HEADING, - new Page.GetByRoleOptions().setName("Product 2"))))) + .setHas(page.getByRole(AriaRole.LIST) + .getByRole(AriaRole.HEADING, + new Locator.GetByRoleOptions().setName("Product 2"))))) .hasCount(1); ``` @@ -644,7 +644,7 @@ Consider a page with two buttons, the first invisible and the second [visible](. * This will only find a second button, because it is visible, and then click it. ```java - page.locator("button").filter(new Locator.FilterOptions.setVisible(true)).click(); + page.locator("button").filter(new Locator.FilterOptions().setVisible(true)).click(); ``` ## Lists @@ -878,7 +878,7 @@ rowLocator .setHas(page.getByRole( AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Say goodbye")))) - .screenshot(new Page.ScreenshotOptions().setPath("screenshot.png")); + .screenshot(new Locator.ScreenshotOptions().setPath(Paths.get("screenshot.png"))); ``` You should now have a "screenshot.png" file in your project's root directory. diff --git a/nodejs/versioned_docs/images/timeline.png b/nodejs/versioned_docs/images/timeline.png new file mode 100644 index 0000000000..4d1a12035c Binary files /dev/null and b/nodejs/versioned_docs/images/timeline.png differ diff --git a/nodejs/versioned_docs/version-stable/api/class-browsertype.mdx b/nodejs/versioned_docs/version-stable/api/class-browsertype.mdx index ff8b676b9a..5258a0f843 100644 --- a/nodejs/versioned_docs/version-stable/api/class-browsertype.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-browsertype.mdx @@ -124,6 +124,9 @@ const page = defaultContext.pages()[0]; - `headers` [Object]<[string], [string]> *(optional)* Added in: v1.11# Additional HTTP headers to be sent with connect request. Optional. + - `isLocal` [boolean] *(optional)* Added in: v1.58# + + Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon the file system being the same between Playwright and the Browser. - `logger` [Logger] *(optional)* Added in: v1.14# :::warning[Deprecated] @@ -203,14 +206,6 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'. - `chromiumSandbox` [boolean] *(optional)*# Enable Chromium sandboxing. Defaults to `false`. - - `devtools` [boolean] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [headless](/api/class-browsertype.mdx#browser-type-launch-option-headless) option will be set `false`. - `downloadsPath` [string] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -234,7 +229,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'. Close the browser process on SIGTERM. Defaults to `true`. - `headless` [boolean] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `ignoreDefaultArgs` [boolean] | [Array]<[string]> *(optional)*# If `true`, Playwright does not pass its own configurations args and only uses the ones from [args](/api/class-browsertype.mdx#browser-type-launch-option-args). If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. @@ -384,14 +379,6 @@ await browserType.launchPersistentContext(userDataDir, options); - `deviceScaleFactor` [number] *(optional)*# Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about [emulating devices with device scale factor](../emulation.mdx#devices). - - `devtools` [boolean] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [headless](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-headless) option will be set `false`. - `downloadsPath` [string] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -434,7 +421,7 @@ await browserType.launchPersistentContext(userDataDir, options); Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - `headless` [boolean] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `httpCredentials` [Object] *(optional)*# - `username` [string] @@ -643,14 +630,6 @@ const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'. - `chromiumSandbox` [boolean] *(optional)*# Enable Chromium sandboxing. Defaults to `false`. - - `devtools` [boolean] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [headless](/api/class-browsertype.mdx#browser-type-launch-server-option-headless) option will be set `false`. - `downloadsPath` [string] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -674,7 +653,7 @@ const { chromium } = require('playwright'); // Or 'webkit' or 'firefox'. Close the browser process on SIGTERM. Defaults to `true`. - `headless` [boolean] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `host` [string] *(optional)* Added in: v1.45# Host to use for the web socket. It is optional and if it is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise. Consider hardening it with picking a specific interface. diff --git a/nodejs/versioned_docs/version-stable/api/class-consolemessage.mdx b/nodejs/versioned_docs/version-stable/api/class-consolemessage.mdx index 508766af36..ce10419b8c 100644 --- a/nodejs/versioned_docs/version-stable/api/class-consolemessage.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-consolemessage.mdx @@ -122,7 +122,7 @@ consoleMessage.type(); ``` **Returns** -- "log" | "debug" | "info" | "error" | "warning" | "dir" | "dirxml" | "table" | "trace" | "clear" | "startGroup" | "startGroupCollapsed" | "endGroup" | "assert" | "profile" | "profileEnd" | "count" | "timeEnd"# +- "log" | "debug" | "info" | "error" | "warning" | "dir" | "dirxml" | "table" | "trace" | "clear" | "startGroup" | "startGroupCollapsed" | "endGroup" | "assert" | "profile" | "profileEnd" | "count" | "time" | "timeEnd"# --- diff --git a/nodejs/versioned_docs/version-stable/api/class-locator.mdx b/nodejs/versioned_docs/version-stable/api/class-locator.mdx index 623712ee78..e8c54761c3 100644 --- a/nodejs/versioned_docs/version-stable/api/class-locator.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-locator.mdx @@ -557,7 +557,7 @@ await button.click(); Added in: v1.57locator.description -Returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the description when available. +Returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. Prefer [locator.toString()](/api/class-locator.mdx#locator-to-string) for a human-readable representation, as it uses the description when available. **Usage** @@ -2330,6 +2330,23 @@ await locator.textContent(options); --- +### toString {#locator-to-string} + +Added in: v1.57locator.toString + +Returns a human-readable representation of the locator, using the [locator.description()](/api/class-locator.mdx#locator-description) if one exists; otherwise, it generates a string based on the locator's selector. + +**Usage** + +```js +locator.toString(); +``` + +**Returns** +- [string]# + +--- + ### uncheck {#locator-uncheck} Added in: v1.14locator.uncheck diff --git a/nodejs/versioned_docs/version-stable/api/class-route.mdx b/nodejs/versioned_docs/version-stable/api/class-route.mdx index f8092afc9e..42ffe92fed 100644 --- a/nodejs/versioned_docs/version-stable/api/class-route.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-route.mdx @@ -99,7 +99,9 @@ The [headers](/api/class-route.mdx#route-continue-option-headers) option applies :::warning -The `Cookie` header cannot be overridden using this method. If a value is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use [browserContext.addCookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). +Some request headers are **forbidden** and cannot be overridden (for example, `Cookie`, `Host`, `Content-Length` and others, see [this MDN page](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header) for full list). If an override is provided for a forbidden header, it will be ignored and the original request header will be used. + +To set custom cookies, use [browserContext.addCookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). ::: --- diff --git a/nodejs/versioned_docs/version-stable/api/class-testconfig.mdx b/nodejs/versioned_docs/version-stable/api/class-testconfig.mdx index 0b6c9d5045..97619298fd 100644 --- a/nodejs/versioned_docs/version-stable/api/class-testconfig.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-testconfig.mdx @@ -1079,7 +1079,7 @@ export default defineConfig({ webServer: { command: 'npm run start', wait: { - stdout: '/Listening on port (?\\d+)/' + stdout: /Listening on port (?\d+)/ }, }, }); @@ -1135,10 +1135,10 @@ test('homepage', async ({ page }) => { - `wait` [Object] *(optional)* - `stdout` [RegExp] *(optional)* - Regular expression to wait for in the `stdout` of the command output. Named capture groups are stored in the environment, for example `/Listening on port (?\\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. + Regular expression to wait for in the `stdout` of the command output. Named capture groups are stored in the environment, for example `/Listening on port (?\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. - `stderr` [RegExp] *(optional)* - Regular expression to wait for in the `stderr` of the command output. Named capture groups are stored in the environment, for example `/Listening on port (?\\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. + Regular expression to wait for in the `stderr` of the command output. Named capture groups are stored in the environment, for example `/Listening on port (?\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. Consider command started only when given output has been produced. - `timeout` [number] *(optional)* diff --git a/nodejs/versioned_docs/version-stable/api/class-testoptions.mdx b/nodejs/versioned_docs/version-stable/api/class-testoptions.mdx index 022953ddf9..6e108dd169 100644 --- a/nodejs/versioned_docs/version-stable/api/class-testoptions.mdx +++ b/nodejs/versioned_docs/version-stable/api/class-testoptions.mdx @@ -454,7 +454,7 @@ export default defineConfig({ Added in: v1.10testOptions.headless -Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. +Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. **Usage** diff --git a/nodejs/versioned_docs/version-stable/docker.mdx b/nodejs/versioned_docs/version-stable/docker.mdx index 8407f59341..1fdd5d7137 100644 --- a/nodejs/versioned_docs/version-stable/docker.mdx +++ b/nodejs/versioned_docs/version-stable/docker.mdx @@ -115,6 +115,24 @@ This makes `hostmachine` point to the host's localhost. Your tests should use `h When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container. ::: +### Connecting using noVNC and GitHub Codespaces + +For Docker and GitHub Codespaces environments, you can view and generate tests using the `noVNC` viewer built into the Docker image. In order for the VNC webviewer to be accessible outside of the container, you can enable the `desktop-lite` feature and specify the `webPort` in your `.devcontainer/devcontainer.json` file: + +```json +{ + "image": "mcr.microsoft.com/playwright:v1.57.0", + "forwardPorts": [6080], + "features": { + "desktop-lite": { + "webPort": "6080" + } + } +} +``` + +Once this is enabled you can open the port specified in a new browser tab and you will have access to the `noVNC` web viewer. This will enable you to record tests, pick selectors, and use codegen directly on your container. + ## Image tags See [all available image tags]. diff --git a/nodejs/versioned_docs/version-stable/release-notes.mdx b/nodejs/versioned_docs/version-stable/release-notes.mdx index f4bee905bf..e0b9e6179b 100644 --- a/nodejs/versioned_docs/version-stable/release-notes.mdx +++ b/nodejs/versioned_docs/version-stable/release-notes.mdx @@ -9,6 +9,41 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.58 + +### Timeline + +If you're using [merged reports](./test-sharding.mdx#merging-reports-from-multiple-environments), the HTML report Speedboard tab now shows the Timeline: + +![Timeline chart in the HTML report](../images/timeline.png) + +### UI Mode and Trace Viewer Improvements +- New 'system' theme option follows your OS dark/light mode preference +- Search functionality (Cmd/Ctrl+F) is now available in code editors +- Network details panel has been reorganized for better usability +- JSON responses are now automatically formatted for readability + +Thanks to [@cpAdm](https://github.com/cpAdm) for contributing these improvements! + +### Miscellaneous + +[browserType.connectOverCDP()](/api/class-browsertype.mdx#browser-type-connect-over-cdp) now accepts an `isLocal` option. When set to `true`, it tells Playwright that it runs on the same host as the CDP server, enabling file system optimizations. + +### Breaking Changes ⚠️ +- Removed `_react` and `_vue` selectors. See [locators guide](./locators.mdx) for alternatives. +- Removed `:light` selector engine suffix. Use standard CSS selectors instead. +- Option `devtools` from [browserType.launch()](/api/class-browsertype.mdx#browser-type-launch) has been removed. Use `args: ['--auto-open-devtools-for-tabs']` instead. +- Removed macOS 13 support for WebKit. We recommend to upgrade your macOS version, or keep using an older Playwright version. + +### Browser Versions +- Chromium 145.0.7632.6 +- Mozilla Firefox 146.0.1 +- WebKit 26.0 + +This version was also tested against the following stable channels: +- Google Chrome 144 +- Microsoft Edge 144 + ## Version 1.57 ### Speedboard @@ -42,7 +77,7 @@ export default defineConfig({ webServer: { command: 'npm run start', wait: { - stdout: '/Listening on port (?\\d+)/' + stdout: /Listening on port (?\d+)/ }, }, }); @@ -53,7 +88,7 @@ If you include a named capture group into the expression, then Playwright will p ```js import { test, expect } from '@playwright/test'; -test.use({ baseUrl: `http://localhost:${process.env.MY_SERVER_PORT ?? 3000}` }); +test.use({ baseURL: `http://localhost:${process.env.MY_SERVER_PORT ?? 3000}` }); test('homepage', async ({ page }) => { await page.goto('/'); @@ -69,7 +104,7 @@ After 3 years of being deprecated, we removed `page.accessibility` from our API. ### 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. -- [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. +- [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()](/api/class-locator.mdx#locator-to-string) 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. - Console messages from Service Workers are dispatched through [worker.on('console')](/api/class-worker.mdx#worker-event-console). You can opt out of this using the `PLAYWRIGHT_DISABLE_SERVICE_WORKER_CONSOLE` environment variable. diff --git a/nodejs/versioned_docs/version-stable/test-cli.mdx b/nodejs/versioned_docs/version-stable/test-cli.mdx index e9ba14f9ea..2ef65fb26b 100644 --- a/nodejs/versioned_docs/version-stable/test-cli.mdx +++ b/nodejs/versioned_docs/version-stable/test-cli.mdx @@ -126,6 +126,18 @@ Options `--test-list` and `--test-list-invert` accept a path to a test list file # This is a test list file. # It can include comments and empty lines. +# Run ALL tests in a file: +path/to/example.spec.ts + +# Run all tests in a file for a specific project: +[chromium] › path/to/example.spec.ts + +# Run all tests in a specific group/suite: +path/to/example.spec.ts › suite name + +# Run all tests in a nested group: +path/to/example.spec.ts › outer suite › inner suite + # Fully qualified test with a project: [chromium] › path/to/example.spec.ts:3:9 › suite › nested suite › example test diff --git a/nodejs/versioned_docs/version-stable/test-fixtures.mdx b/nodejs/versioned_docs/version-stable/test-fixtures.mdx index a53c6f0efc..5a99d045d7 100644 --- a/nodejs/versioned_docs/version-stable/test-fixtures.mdx +++ b/nodejs/versioned_docs/version-stable/test-fixtures.mdx @@ -367,6 +367,8 @@ Playwright Test uses [worker processes](./test-parallel.mdx) to run test files. Below we'll create an `account` fixture that will be shared by all tests in the same worker, and override the `page` fixture to log in to this account for each test. To generate unique accounts, we'll use the [workerInfo.workerIndex](/api/class-workerinfo.mdx#worker-info-worker-index) that is available to any test or fixture. Note the tuple-like syntax for the worker fixture - we have to pass `{scope: 'worker'}` so that test runner sets this fixture up once per worker. +In addition to only being run once per worker, worker-scoped fixtures also get a separate timeout equal to the default test timeout. You can change it by passing the `timeout` option. See [fixture timeout](#fixture-timeout) for more details. + ```js title="my-test.ts" import { test as base } from '@playwright/test'; @@ -447,7 +449,7 @@ export { expect } from '@playwright/test'; ## Fixture timeout -By default, the fixture inherits the timeout value of the test. However, for slow fixtures, especially [worker-scoped](#worker-scoped-fixtures) ones, it is convenient to have a separate timeout. This way you can keep the overall test timeout small, and give the slow fixture more time. +Fixture is considered to be a part of a test, and so its setup and teardown running time counts towards the test timeout. Therefore, a slow fixture may cause test timeouts. You can set a separate larger timeout for such a fixture, and keep the overall test timeout small. ```js import { test as base, expect } from '@playwright/test'; @@ -464,6 +466,8 @@ test('example test', async ({ slowFixture }) => { }); ``` +Unlike regular test-scoped fixtures, each [worker-scoped](#worker-scoped-fixtures) fixture has its own timeout, equal to the test timeout. You can change the timeout for a worker-scoped fixture in the same way. + ## Fixtures-options Playwright Test supports running multiple test projects that can be configured separately. You can use "option" fixtures to make your configuration options declarative and type safe. Learn more about [parameterizing tests](./test-parameterize.mdx). diff --git a/nodejs/versioned_docs/version-stable/test-typescript.mdx b/nodejs/versioned_docs/version-stable/test-typescript.mdx index 5f40834e34..eb9cc49fcc 100644 --- a/nodejs/versioned_docs/version-stable/test-typescript.mdx +++ b/nodejs/versioned_docs/version-stable/test-typescript.mdx @@ -51,16 +51,15 @@ playwright.config.ts ### tsconfig path mapping -Playwright supports [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) declared in the `tsconfig.json`. Make sure that `baseUrl` is also set. +Playwright supports [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) declared in the `tsconfig.json`. Here is an example `tsconfig.json` that works with Playwright: ```json title="tsconfig.json" { "compilerOptions": { - "baseUrl": ".", "paths": { - "@myhelper/*": ["packages/myhelper/*"] // This mapping is relative to "baseUrl". + "@myhelper/*": ["packages/myhelper/*"] // This mapping is relative to the tsconfig. } } } diff --git a/nodejs/versioned_docs/version-stable/test-ui-mode.mdx b/nodejs/versioned_docs/version-stable/test-ui-mode.mdx index 2cc4006311..5c80d026ef 100644 --- a/nodejs/versioned_docs/version-stable/test-ui-mode.mdx +++ b/nodejs/versioned_docs/version-stable/test-ui-mode.mdx @@ -127,7 +127,7 @@ npx playwright test --ui-port=8080 --ui-host=0.0.0.0 ``` :::note -Be aware that when specifying the `--ui-host=0.0.0.0` flag, UI Mode with your traces, the passwords and secrets is accessible from other machines inside your network. In the case of GitHub Codespaces, the ports are only accessible from your account by default. +Be aware that when specifying the `--ui-host=0.0.0.0` flag, UI Mode with your traces, the passwords and secrets are accessible from other machines inside your network. In the case of GitHub Codespaces, the ports are only accessible from your account by default. ::: diff --git a/nodejs/versioned_docs/version-stable/test-webserver.mdx b/nodejs/versioned_docs/version-stable/test-webserver.mdx index c0985ec1d7..94839ab970 100644 --- a/nodejs/versioned_docs/version-stable/test-webserver.mdx +++ b/nodejs/versioned_docs/version-stable/test-webserver.mdx @@ -38,13 +38,13 @@ export default defineConfig({ | `gracefulShutdown` | How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: 'SIGTERM', timeout: 500 }`, the process group is sent a `SIGTERM` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGINT` as the signal instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGTERM` and `SIGINT` signals, so this option is ignored on Windows. Note that shutting down a Docker container requires `SIGTERM`. | | `ignoreHTTPSErrors` | Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`. | | `name` | Specifies a custom name for the web server. This name will be prefixed to log messages. Defaults to `[WebServer]`. | -| `port` | **Deprecated**. User `url` instead. The port that your http server is expected to appear on. It does wait until it accepts connections. Either `port` or `url` should be specified. | +| `port` | **Deprecated**. Use `url` instead. The port that your http server is expected to appear on. It does wait until it accepts connections. Either `port` or `url` should be specified. | | `reuseExistingServer`| If `true`, it will re-use an existing server on the `port` or `url` when available. If no server is running on that `port` or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is listening on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server when running tests locally. | | `stderr` | Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. | | `stdout` | If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`. | | `timeout` | How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. | | `url`| URL of your http server that is expected to return a 2xx, 3xx, 400, 401, 402, or 403 status code when the server is ready to accept connections. Either `port` or `url` should be specified. | -| `wait` | Consider command started only when given output has been produced. Takes an object with optional `stdout` and/or `stderr` regular expressions. Named capture groups in the regex are stored in the environment, for example `/Listening on port (?\\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. | +| `wait` | Consider command started only when given output has been produced. Takes an object with optional `stdout` and/or `stderr` regular expressions. Named capture groups in the regex are stored in the environment, for example `/Listening on port (?\d+)/` will store the port number in `process.env['MY_SERVER_PORT']`. | ## Adding a server timeout diff --git a/python/versioned_docs/images/timeline.png b/python/versioned_docs/images/timeline.png new file mode 100644 index 0000000000..4d1a12035c Binary files /dev/null and b/python/versioned_docs/images/timeline.png differ diff --git a/python/versioned_docs/version-stable/api/class-browsertype.mdx b/python/versioned_docs/version-stable/api/class-browsertype.mdx index bf6bc4810d..38c909a7e8 100644 --- a/python/versioned_docs/version-stable/api/class-browsertype.mdx +++ b/python/versioned_docs/version-stable/api/class-browsertype.mdx @@ -167,6 +167,9 @@ page = default_context.pages[0] - `headers` [Dict]\[[str], [str]\] *(optional)* Added in: v1.11# Additional HTTP headers to be sent with connect request. Optional. +- `is_local` [bool] *(optional)* Added in: v1.58# + + Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon the file system being the same between Playwright and the Browser. - `slow_mo` [float] *(optional)* Added in: v1.11# Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. @@ -242,14 +245,6 @@ browser = await playwright.chromium.launch( # or "firefox" or "webkit". - `chromium_sandbox` [bool] *(optional)*# Enable Chromium sandboxing. Defaults to `false`. -- `devtools` [bool] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [headless](/api/class-browsertype.mdx#browser-type-launch-option-headless) option will be set `false`. - `downloads_path` [Union]\[[str], [pathlib.Path]\] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -275,7 +270,7 @@ browser = await playwright.chromium.launch( # or "firefox" or "webkit". Close the browser process on SIGTERM. Defaults to `true`. - `headless` [bool] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `ignore_default_args` [bool] | [List]\[[str]\] *(optional)*# If `true`, Playwright does not pass its own configurations args and only uses the ones from [args](/api/class-browsertype.mdx#browser-type-launch-option-args). If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. @@ -416,14 +411,6 @@ browser_type.launch_persistent_context(user_data_dir, **kwargs) - `device_scale_factor` [float] *(optional)*# Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about [emulating devices with device scale factor](../emulation.mdx#devices). -- `devtools` [bool] *(optional)*# - - :::warning[Deprecated] - Use [debugging tools](../debug.mdx) instead. - ::: - - - **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the [headless](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-headless) option will be set `false`. - `downloads_path` [Union]\[[str], [pathlib.Path]\] *(optional)*# If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. @@ -468,7 +455,7 @@ browser_type.launch_persistent_context(user_data_dir, **kwargs) Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - `headless` [bool] *(optional)*# - Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true` unless the [devtools](/api/class-browsertype.mdx#browser-type-launch-option-devtools) option is `true`. + Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - `http_credentials` [Dict] *(optional)*# - `username` [str] diff --git a/python/versioned_docs/version-stable/api/class-consolemessage.mdx b/python/versioned_docs/version-stable/api/class-consolemessage.mdx index 6996f8f1cb..4ea4500ed7 100644 --- a/python/versioned_docs/version-stable/api/class-consolemessage.mdx +++ b/python/versioned_docs/version-stable/api/class-consolemessage.mdx @@ -152,7 +152,7 @@ console_message.type ``` **Returns** -- "log" | "debug" | "info" | "error" | "warning" | "dir" | "dirxml" | "table" | "trace" | "clear" | "startGroup" | "startGroupCollapsed" | "endGroup" | "assert" | "profile" | "profileEnd" | "count" | "timeEnd"# +- "log" | "debug" | "info" | "error" | "warning" | "dir" | "dirxml" | "table" | "trace" | "clear" | "startGroup" | "startGroupCollapsed" | "endGroup" | "assert" | "profile" | "profileEnd" | "count" | "time" | "timeEnd"# --- diff --git a/python/versioned_docs/version-stable/api/class-locator.mdx b/python/versioned_docs/version-stable/api/class-locator.mdx index dcdf23e3e0..e24ae4b56d 100644 --- a/python/versioned_docs/version-stable/api/class-locator.mdx +++ b/python/versioned_docs/version-stable/api/class-locator.mdx @@ -3324,7 +3324,7 @@ await frame_locator.get_by_role("button").click() Added in: v1.57locator.description -Returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the description when available. +Returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe). Returns `null` if no custom description has been set. **Usage** diff --git a/python/versioned_docs/version-stable/api/class-locatorassertions.mdx b/python/versioned_docs/version-stable/api/class-locatorassertions.mdx index 5f11b446be..ef4ec5aa2c 100644 --- a/python/versioned_docs/version-stable/api/class-locatorassertions.mdx +++ b/python/versioned_docs/version-stable/api/class-locatorassertions.mdx @@ -1418,7 +1418,7 @@ Let's see how we can use the assertion: from playwright.sync_api import expect # ✓ Contains the right items in the right order -expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3", "Text 4"]) +expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3"]) # ✖ Wrong order expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"]) @@ -1437,7 +1437,7 @@ expect(page.locator("ul")).to_contain_text(["Text 3"]) from playwright.async_api import expect # ✓ Contains the right items in the right order -await expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3", "Text 4"]) +await expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3"]) # ✖ Wrong order await expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"]) diff --git a/python/versioned_docs/version-stable/api/class-route.mdx b/python/versioned_docs/version-stable/api/class-route.mdx index 652f2b46ce..74c0962ed5 100644 --- a/python/versioned_docs/version-stable/api/class-route.mdx +++ b/python/versioned_docs/version-stable/api/class-route.mdx @@ -128,7 +128,9 @@ The [headers](/api/class-route.mdx#route-continue-option-headers) option applies :::warning -The `Cookie` header cannot be overridden using this method. If a value is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use [browser_context.add_cookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). +Some request headers are **forbidden** and cannot be overridden (for example, `Cookie`, `Host`, `Content-Length` and others, see [this MDN page](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header) for full list). If an override is provided for a forbidden header, it will be ignored and the original request header will be used. + +To set custom cookies, use [browser_context.add_cookies()](/api/class-browsercontext.mdx#browser-context-add-cookies). ::: --- diff --git a/python/versioned_docs/version-stable/docker.mdx b/python/versioned_docs/version-stable/docker.mdx index 94e8d9f152..a93756b1b0 100644 --- a/python/versioned_docs/version-stable/docker.mdx +++ b/python/versioned_docs/version-stable/docker.mdx @@ -132,6 +132,24 @@ This makes `hostmachine` point to the host's localhost. Your tests should use `h When running tests remotely, ensure the Playwright version in your tests matches the version running in the Docker container. ::: +### Connecting using noVNC and GitHub Codespaces + +For Docker and GitHub Codespaces environments, you can view and generate tests using the `noVNC` viewer built into the Docker image. In order for the VNC webviewer to be accessible outside of the container, you can enable the `desktop-lite` feature and specify the `webPort` in your `.devcontainer/devcontainer.json` file: + +```json +{ + "image": "mcr.microsoft.com/playwright:v1.57.0", + "forwardPorts": [6080], + "features": { + "desktop-lite": { + "webPort": "6080" + } + } +} +``` + +Once this is enabled you can open the port specified in a new browser tab and you will have access to the `noVNC` web viewer. This will enable you to record tests, pick selectors, and use codegen directly on your container. + ## Image tags See [all available image tags].