diff --git a/dotnet/docs/api/class-locator.mdx b/dotnet/docs/api/class-locator.mdx index 1c461656683..82b4a425bbb 100644 --- a/dotnet/docs/api/class-locator.mdx +++ b/dotnet/docs/api/class-locator.mdx @@ -2313,6 +2313,29 @@ When all steps combined have not finished during the specified [Timeout](/api/cl --- +### Visible {#locator-visible} + +Added in: v1.51locator.Visible + +Returns a locator that only matches [visible](../actionability.mdx#visible) elements. + +**Usage** + +```csharp +Locator.Visible(options); +``` + +**Arguments** +- `options` `LocatorVisibleOptions?` *(optional)* + - `Visible` [bool]? *(optional)*# + + Whether to match visible or invisible elements. + +**Returns** +- [Locator]# + +--- + ### WaitForAsync {#locator-wait-for} Added in: v1.16locator.WaitForAsync diff --git a/dotnet/docs/locators.mdx b/dotnet/docs/locators.mdx index 3e99694c76d..6a80dfe5b1a 100644 --- a/dotnet/docs/locators.mdx +++ b/dotnet/docs/locators.mdx @@ -641,7 +641,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. ```csharp - await page.Locator("button").Locator("visible=true").ClickAsync(); + await page.Locator("button").Visible().ClickAsync(); ``` ## Lists diff --git a/java/docs/api/class-locator.mdx b/java/docs/api/class-locator.mdx index 806fc166830..16799d61fb0 100644 --- a/java/docs/api/class-locator.mdx +++ b/java/docs/api/class-locator.mdx @@ -2313,6 +2313,30 @@ When all steps combined have not finished during the specified [setTimeout](/api --- +### visible {#locator-visible} + +Added in: v1.51locator.visible + +Returns a locator that only matches [visible](../actionability.mdx#visible) elements. + +**Usage** + +```java +Locator.visible(); +Locator.visible(options); +``` + +**Arguments** +- `options` `Locator.VisibleOptions` *(optional)* + - `setVisible` [boolean] *(optional)*# + + Whether to match visible or invisible elements. + +**Returns** +- [Locator]# + +--- + ### waitFor {#locator-wait-for} Added in: v1.16locator.waitFor diff --git a/java/docs/locators.mdx b/java/docs/locators.mdx index e0a1b717207..27ef9c94e32 100644 --- a/java/docs/locators.mdx +++ b/java/docs/locators.mdx @@ -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").locator("visible=true").click(); + page.locator("button").visible().click(); ``` ## Lists diff --git a/nodejs/docs/api/class-locator.mdx b/nodejs/docs/api/class-locator.mdx index 3158db0f6e0..8350cb59bec 100644 --- a/nodejs/docs/api/class-locator.mdx +++ b/nodejs/docs/api/class-locator.mdx @@ -2323,6 +2323,30 @@ When all steps combined have not finished during the specified [timeout](/api/cl --- +### visible {#locator-visible} + +Added in: v1.51locator.visible + +Returns a locator that only matches [visible](../actionability.mdx#visible) elements. + +**Usage** + +```js +locator.visible(); +locator.visible(options); +``` + +**Arguments** +- `options` [Object] *(optional)* + - `visible` [boolean] *(optional)*# + + Whether to match visible or invisible elements. + +**Returns** +- [Locator]# + +--- + ### waitFor {#locator-wait-for} Added in: v1.16locator.waitFor diff --git a/nodejs/docs/api/class-testconfig.mdx b/nodejs/docs/api/class-testconfig.mdx index 687c9d23edb..aa3366691bf 100644 --- a/nodejs/docs/api/class-testconfig.mdx +++ b/nodejs/docs/api/class-testconfig.mdx @@ -343,7 +343,7 @@ export default defineConfig({ Metadata contains key-value pairs to be included in the report. For example, HTML report will display it as key-value pairs, and JSON report will include metadata serialized as json. -See also [testConfig.populateGitInfo](/api/class-testconfig.mdx#test-config-populate-git-info) that populates metadata. +Providing `'git.commit.info': {}` property will populate it with the git commit details. This is useful for CI/CD environments. **Usage** @@ -418,31 +418,6 @@ test('example test', async ({}, testInfo) => { --- -### populateGitInfo {#test-config-populate-git-info} - -Added in: v1.51testConfig.populateGitInfo - -Whether to populate `'git.commit.info'` field of the [testConfig.metadata](/api/class-testconfig.mdx#test-config-metadata) with Git commit info and CI/CD information. - -This information will appear in the HTML and JSON reports and is available in the Reporter API. - -On Github Actions, this feature is enabled by default. - -**Usage** - -```js title="playwright.config.ts" -import { defineConfig } from '@playwright/test'; - -export default defineConfig({ - populateGitInfo: !!process.env.CI, -}); -``` - -**Type** -- [boolean] - ---- - ### preserveOutput {#test-config-preserve-output} Added in: v1.10testConfig.preserveOutput @@ -963,7 +938,7 @@ import { defineConfig } from '@playwright/test'; export default defineConfig({ webServer: { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', timeout: 120 * 1000, reuseExistingServer: !process.env.CI, }, @@ -992,19 +967,19 @@ export default defineConfig({ webServer: [ { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', timeout: 120 * 1000, reuseExistingServer: !process.env.CI, }, { command: 'npm run backend', - url: 'http://127.0.0.1:3333', + url: 'http://localhost:3333', timeout: 120 * 1000, reuseExistingServer: !process.env.CI, } ], use: { - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', }, }); ``` diff --git a/nodejs/docs/locators.mdx b/nodejs/docs/locators.mdx index 14292230177..9c6efe7be7f 100644 --- a/nodejs/docs/locators.mdx +++ b/nodejs/docs/locators.mdx @@ -624,7 +624,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. ```js - await page.locator('button').locator('visible=true').click(); + await page.locator('button').visible().click(); ``` ## Lists diff --git a/nodejs/docs/test-configuration.mdx b/nodejs/docs/test-configuration.mdx index e220cea3d1d..007e50a3346 100644 --- a/nodejs/docs/test-configuration.mdx +++ b/nodejs/docs/test-configuration.mdx @@ -38,7 +38,7 @@ export default defineConfig({ use: { // Base URL to use in actions like `await page.goto('/')`. - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', // Collect trace when retrying the failed test. trace: 'on-first-retry', @@ -53,7 +53,7 @@ export default defineConfig({ // Run your local dev server before starting the tests. webServer: { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, }, }); diff --git a/nodejs/docs/test-use-options.mdx b/nodejs/docs/test-use-options.mdx index f1a2b016444..f0eb76db0ba 100644 --- a/nodejs/docs/test-use-options.mdx +++ b/nodejs/docs/test-use-options.mdx @@ -20,7 +20,7 @@ import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { // Base URL to use in actions like `await page.goto('/')`. - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', // Populates context with given storage state. storageState: 'state.json', diff --git a/nodejs/docs/test-webserver.mdx b/nodejs/docs/test-webserver.mdx index 25e3298c6d1..f369a134f13 100644 --- a/nodejs/docs/test-webserver.mdx +++ b/nodejs/docs/test-webserver.mdx @@ -21,7 +21,7 @@ export default defineConfig({ // Run your local dev server before starting the tests webServer: { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, stdout: 'ignore', stderr: 'pipe', @@ -55,7 +55,7 @@ export default defineConfig({ // Run your local dev server before starting the tests webServer: { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, timeout: 120 * 1000, }, @@ -66,7 +66,7 @@ export default defineConfig({ It is also recommended to specify the `baseURL` in the `use: {}` section of your config, so that tests can use relative urls and you don't have to specify the full URL over and over again. -When using [page.goto()](/api/class-page.mdx#page-goto), [page.route()](/api/class-page.mdx#page-route), [page.waitForURL()](/api/class-page.mdx#page-wait-for-url), [page.waitForRequest()](/api/class-page.mdx#page-wait-for-request), or [page.waitForResponse()](/api/class-page.mdx#page-wait-for-response) it takes the base URL in consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. For Example, by setting the baseURL to `http://127.0.0.1:3000` and navigating to `/login` in your tests, Playwright will run the test using `http://127.0.0.1:3000/login`. +When using [page.goto()](/api/class-page.mdx#page-goto), [page.route()](/api/class-page.mdx#page-route), [page.waitForURL()](/api/class-page.mdx#page-wait-for-url), [page.waitForRequest()](/api/class-page.mdx#page-wait-for-request), or [page.waitForResponse()](/api/class-page.mdx#page-wait-for-response) it takes the base URL in consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. For Example, by setting the baseURL to `http://localhost:3000` and navigating to `/login` in your tests, Playwright will run the test using `http://localhost:3000/login`. ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; @@ -77,11 +77,11 @@ export default defineConfig({ // Run your local dev server before starting the tests webServer: { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, }, use: { - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', }, }); ``` @@ -92,7 +92,7 @@ Now you can use a relative path when navigating the page: import { test } from '@playwright/test'; test('test', async ({ page }) => { - // This will navigate to http://127.0.0.1:3000/login + // This will navigate to http://localhost:3000/login await page.goto('./login'); }); ``` @@ -108,19 +108,19 @@ export default defineConfig({ webServer: [ { command: 'npm run start', - url: 'http://127.0.0.1:3000', + url: 'http://localhost:3000', timeout: 120 * 1000, reuseExistingServer: !process.env.CI, }, { command: 'npm run backend', - url: 'http://127.0.0.1:3333', + url: 'http://localhost:3333', timeout: 120 * 1000, reuseExistingServer: !process.env.CI, } ], use: { - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', }, }); ``` diff --git a/python/docs/api/class-locator.mdx b/python/docs/api/class-locator.mdx index ba65d89c717..f440dab3cd8 100644 --- a/python/docs/api/class-locator.mdx +++ b/python/docs/api/class-locator.mdx @@ -3134,6 +3134,29 @@ When all steps combined have not finished during the specified [timeout](/api/cl --- +### visible {#locator-visible} + +Added in: v1.51locator.visible + +Returns a locator that only matches [visible](../actionability.mdx#visible) elements. + +**Usage** + +```python +locator.visible() +locator.visible(**kwargs) +``` + +**Arguments** +- `visible` [bool] *(optional)*# + + Whether to match visible or invisible elements. + +**Returns** +- [Locator]# + +--- + ### wait_for {#locator-wait-for} Added in: v1.16locator.wait_for diff --git a/python/docs/locators.mdx b/python/docs/locators.mdx index 6d97b5dfaf8..cfff90bd9d1 100644 --- a/python/docs/locators.mdx +++ b/python/docs/locators.mdx @@ -1318,14 +1318,14 @@ Consider a page with two buttons, the first invisible and the second [visible](. ```py - page.locator("button").locator("visible=true").click() + page.locator("button").visible().click() ``` ```py - await page.locator("button").locator("visible=true").click() + await page.locator("button").visible().click() ```