Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: rework Selectors to Other Locators (#19244)

Dmitry Gozmane55a2bdf16c1
diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.md
index 2861d04abe..1b5f2621ff 100644
--- a/docs/src/api/class-elementhandle.md
+++ b/docs/src/api/class-elementhandle.md
@@ -379,8 +379,7 @@ Optional event-specific initialization properties.
Returns the return value of [`param: expression`].
The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
-argument to [`param: expression`]. See [Working with selectors](../selectors.md) for more
-details. If no elements match the selector, the method throws an error.
+argument to [`param: expression`]. If no elements match the selector, the method throws an error.
If [`param: expression`] returns a [Promise], then [`method: ElementHandle.evalOnSelector`] would wait for the promise to resolve and return its
value.
@@ -439,8 +438,7 @@ Optional argument to pass to [`param: expression`].
Returns the return value of [`param: expression`].
The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
-matched elements as a first argument to [`param: expression`]. See
-[Working with selectors](../selectors.md) for more details.
+matched elements as a first argument to [`param: expression`].
If [`param: expression`] returns a [Promise], then [`method: ElementHandle.evalOnSelectorAll`] would wait for the promise to resolve and return its
value.
@@ -677,8 +675,7 @@ Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
- alias-js: $
- returns: <[null]|[ElementHandle]>
-The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See
-[Working with selectors](../selectors.md) for more details. If no elements match the selector,
+The method finds an element matching the specified selector in the `ElementHandle`'s subtree. If no elements match the selector,
returns `null`.
### param: ElementHandle.querySelector.selector = %%-query-selector-%%
@@ -691,8 +688,7 @@ returns `null`.
- alias-js: $$
- returns: <[Array]<[ElementHandle]>>
-The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See
-[Working with selectors](../selectors.md) for more details. If no elements match the selector,
+The method finds all elements matching the specified selector in the `ElementHandle`s subtree. If no elements match the selector,
returns empty array.
### param: ElementHandle.querySelectorAll.selector = %%-query-selector-%%
diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.md
index 5f38257e53..49b77defd3 100644
--- a/docs/src/api/class-frame.md
+++ b/docs/src/api/class-frame.md
@@ -479,7 +479,7 @@ Optional event-specific initialization properties.
Returns the return value of [`param: expression`].
The method finds an element matching the specified selector within the frame and passes it as a first argument to
-[`param: expression`]. See [Working with selectors](../selectors.md) for more details. If no
+[`param: expression`]. If no
elements match the selector, the method throws an error.
If [`param: expression`] returns a [Promise], then [`method: Frame.evalOnSelector`] would wait for the promise to resolve and return its
@@ -544,8 +544,7 @@ Optional argument to pass to [`param: expression`].
Returns the return value of [`param: expression`].
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
-as a first argument to [`param: expression`]. See [Working with selectors](../selectors.md) for
-more details.
+as a first argument to [`param: expression`].
If [`param: expression`] returns a [Promise], then [`method: Frame.evalOnSelectorAll`] would wait for the promise to resolve and return its
value.
@@ -1367,8 +1366,7 @@ Returns the ElementHandle pointing to the frame element.
The use of [ElementHandle] is discouraged, use [Locator] objects and web-first assertions instead.
:::
-The method finds an element matching the specified selector within the frame. See
-[Working with selectors](../selectors.md) for more details. If no elements match the selector,
+The method finds an element matching the specified selector within the frame. If no elements match the selector,
returns `null`.
### param: Frame.querySelector.selector = %%-query-selector-%%
@@ -1391,8 +1389,7 @@ Returns the ElementHandles pointing to the frame elements.
The use of [ElementHandle] is discouraged, use [Locator] objects instead.
:::
-The method finds all elements matching the specified selector within the frame. See
-[Working with selectors](../selectors.md) for more details. If no elements match the selector,
+The method finds all elements matching the specified selector within the frame. If no elements match the selector,
returns empty array.
### param: Frame.querySelectorAll.selector = %%-query-selector-%%
diff --git a/docs/src/api/class-playwright.md b/docs/src/api/class-playwright.md
index ca1e866ddd..843b0b9f1c 100644
--- a/docs/src/api/class-playwright.md
+++ b/docs/src/api/class-playwright.md
@@ -233,7 +233,7 @@ Exposes API that can be used for the Web API testing.
- type: <[Selectors]>
Selectors can be used to install custom selector engines. See
-[Working with selectors](../selectors.md) for more information.
+[extensibility](../extensibility.md) for more information.
## property: Playwright.webkit
* since: v1.8
diff --git a/docs/src/api/class-selectors.md b/docs/src/api/class-selectors.md
index 3d6c3874b6..897f0fab4d 100644
--- a/docs/src/api/class-selectors.md
+++ b/docs/src/api/class-selectors.md
@@ -1,7 +1,7 @@
# class: Selectors
* since: v1.8
-Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
+Selectors can be used to install custom selector engines. See [extensibility](../extensibility.md) for more
information.
## async method: Selectors.register
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index a4bd5ab17d..250e9412cd 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -51,20 +51,17 @@ Whether to bypass the [actionability](../actionability.md) checks. Defaults to `
## input-selector
- `selector` <[string]>
-A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
-[working with selectors](../selectors.md) for more details.
+A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
## input-source
- `source` <[string]>
-A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be used. See
-[working with selectors](../selectors.md) for more details.
+A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be used.
## input-target
- `target` <[string]>
-A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will be used. See
-[working with selectors](../selectors.md) for more details.
+A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will be used.
## input-position
- `position` <[Object]>
@@ -130,12 +127,12 @@ Whether to check or uncheck the checkbox.
## query-selector
- `selector` <[string]>
-A selector to query for. See [working with selectors](../selectors.md) for more details.
+A selector to query for.
## find-selector
- `selector` <[string]>
-A selector to use when resolving DOM element. See [working with selectors](../selectors.md) for more details.
+A selector to use when resolving DOM element.
## wait-for-selector-state
- `state` <[WaitForSelectorState]<"attached"|"detached"|"visible"|"hidden">>
diff --git a/docs/src/ci-intro-js.md b/docs/src/ci-intro-js.md
index 61fac26511..01f9235180 100644
--- a/docs/src/ci-intro-js.md
+++ b/docs/src/ci-intro-js.md
@@ -110,6 +110,6 @@ To learn more about running tests on CI check out our detailed guide on [Continu
## What's Next
-- [Learn how to use Web First Assertions](/test-assertions.md)
-- [Learn how to use Selectors](/selectors.md)
-- [Learn how to use Locators](/locators.md)
+- [Learn how to use Locators](./locators.md)
+- [Learn how to perform Actions](./input.md)
+- [Learn how to write Assertions](./test-assertions.md)
diff --git a/docs/src/debug.md b/docs/src/debug.md
index fe8607493e..e0cad775d9 100644
--- a/docs/src/debug.md
+++ b/docs/src/debug.md
@@ -107,8 +107,7 @@ Using `PWDEBUG=console` will configure the browser for debugging in Developer to
- **Runs headed**: Browsers always launch in headed mode
- **Disables timeout**: Sets default timeout to 0 (= no timeout)
- **Console helper**: Configures a `playwright` object in the browser to generate and highlight
- [Playwright selectors](./selectors.md). This can be used to verify text or
- composite selectors.
+ [Playwright locators](./locators.md). This can be used to verify locators.
```bash tab=bash-bash lang=js
PWDEBUG=console npx playwright test
@@ -201,7 +200,7 @@ pwsh bin/Debug/netX/playwright.ps1 codegen wikipedia.org
### Stepping through the Playwright script
-The Inspector opens up a browser window highlighting the selectors as you step through each line of the test. Use the explore button to find other available [selectors](./selectors.md) which you can then copy into your test file and rerun your tests to see if they pass.
+The Inspector opens up a browser window highlighting the elements as you step through each line of the test. Use the explore button to pick a [locator](./locators.md) which you can then copy into your test file and rerun your tests to see if they pass.
<img width="557" alt="Paused on line" src="https://user-images.githubusercontent.com/883973/108614337-71761580-73ae-11eb-9f61-3d29c52c9520.png"></img>
diff --git a/docs/src/locators.md b/docs/src/locators.md
index 12e56e6cb5..71db0ca3ba 100644
--- a/docs/src/locators.md
+++ b/docs/src/locators.md
@@ -258,7 +258,7 @@ await page
.ClickAsync();
```
-Role locators include [buttons, checkboxes, headings, links, lists, tables, and many more](https://www.w3.org/TR/html-aria/#docconformance) and follow W3C specifications for [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
+Role locators include [buttons, checkboxes, headings, links, lists, tables, and many more](https://www.w3.org/TR/html-aria/#docconformance) and follow W3C specifications for [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that many html elements like `<button>` have an [implicitly defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role locator.
Note that role locators **do not replace** accessibility audits and conformance tests, but rather give early feedback about the ARIA guidelines.
@@ -624,7 +624,7 @@ await page.GetByTestId("directions").ClickAsync();
### Locate by CSS or XPath
-If you absolutely must use CSS or XPath locators, you can use [`method: Page.locator`] to create a locator that takes a [selector](./selectors.md) describing how to find an element in the page. Playwright supports CSS and XPath selectors, and auto-detects them if you omit `css=` or `xpath=` prefix.
+If you absolutely must use CSS or XPath locators, you can use [`method: Page.locator`] to create a locator that takes a selector describing how to find an element in the page. Playwright supports CSS and XPath selectors, and auto-detects them if you omit `css=` or `xpath=` prefix.
```js
await page.locator('css=button').click();
@@ -1502,3 +1502,7 @@ await page.GetByRole(AriaRole.Button).CountAsync();
```
You can explicitly opt-out from strictness check by telling Playwright which element to use when multiple elements match, through [`method: Locator.first`], [`method: Locator.last`], and [`method: Locator.nth`]. These methods are **not recommended** because when your page changes, Playwright may click on an element you did not intend. Instead, follow best practices above to create a locator that uniquely identifies the target element.
+
+## More Locators
+
+For less commonly used locators, look at the [other locators](./other-locators.md) guide.
diff --git a/docs/src/selectors.md b/docs/src/other-locators.md
similarity index 50%
rename from docs/src/selectors.md
rename to docs/src/other-locators.md
index f0dba4fdd9..ddb1a4f03a 100644
--- a/docs/src/selectors.md
+++ b/docs/src/other-locators.md
@@ -1,112 +1,52 @@
---
-id: selectors
-title: "Selectors"
+id: other-locators
+title: "Other Locators"
---
-Selectors are strings that are used to create [Locator]s. Locators are used to perform actions on the elements by means of methods such as [`method: Locator.click`], [`method: Locator.fill`] and alike. For debugging selectors, see [here](./debug-selectors).
+:::tip
+Check out the main [locators guide](./locators) for most common and recommended locators.
+:::
+
+In addition to recommended locators like [`method: Page.getByRole`] and [`method: Page.getByText`], Playwright supports a variety of other locators described in this guide.
+
+
+## CSS locator
-:::info
-Check out our [locators guide](./locators) for more information on our new locators API.
+:::note
+We recommend prioritzing [user-visible locators](./locators.md#quick-guide) like text or accessible role instead of using CSS that is tied to the implementation and could break when the page changes.
:::
-## Text selector
-Text selector locates elements that contain passed text.
+Playwright can locate an element by CSS selector.
```js
-await page.locator('text=Log in').click();
+await page.locator('css=button').click();
```
```java
-page.locator("text=Log in").click();
+page.locator("css=button").click();
```
```python async
-await page.locator("text=Log in").click()
+await page.locator("css=button").click()
```
```python sync
-page.locator("text=Log in").click()
+page.locator("css=button").click()
```
```csharp
-await page.Locator("text=Log in").ClickAsync();
+await page.Locator("css=button").ClickAsync();
```
-Text selector has a few variations:
-
-- `text=Log in` - default matching is case-insensitive, trims whitespace and searches for a substring. For example, `text=Log` matches `<button>Log in</button>`.
-
- ```js
- await page.locator('text=Log in').click();
- ```
- ```java
- page.locator("text=Log in").click();
- ```
- ```python async
- await page.locator("text=Log in").click()
- ```
- ```python sync
- page.locator("text=Log in").click()
- ```
- ```csharp
- await page.Locator("text=Log in").ClickAsync();
- ```
-
-- `text="Log in"` - text body can be escaped with single or double quotes to search for a text node with exact content after trimming whitespace. For example, `text="Log"` does not match `<button>Log in</button>` because `<button>` contains a single text node `"Log in"` that is not equal to `"Log"`. However, `text="Log"` matches `<button> Log <span>in</span></button>`, because `<button>` contains a text node `" Log "`. This exact mode implies case-sensitive matching, so `text="Download"` will not match `<button>download</button>`.
-
- Quoted body follows the usual escaping rules, e.g. use `\"` to escape double quote in a double-quoted string: `text="foo\"bar"`.
-
- ```js
- await page.locator('text="Log in"').click();
- ```
- ```java
- page.locator("text='Log in'").click();
- ```
- ```python async
- await page.locator("text='Log in'").click()
- ```
- ```python sync
- page.locator("text='Log in'").click()
- ```
- ```csharp
- await page.Locator("text='Log in'").ClickAsync();
- ```
-
-- `"Log in"` - selector starting and ending with a quote (either `"` or `'`) is assumed to be a text selector. For example, `"Log in"` is converted to `text="Log in"` internally.
+Playwright augments standard CSS selectors in two ways:
+* CSS selectors pierce open shadow DOM.
+* Playwright adds custom pseudo-classes like `:visible`, `:has-text()`, `:has()`, `:is()`, `:nth-match()` and more.
- ```js
- await page.locator('"Log in"').click();
- ```
- ```java
- page.locator("'Log in'").click();
- ```
- ```python async
- await page.locator("'Log in'").click()
- ```
- ```python sync
- page.locator("'Log in'").click()
- ```
- ```csharp
- await page.Locator("'Log in'").ClickAsync();
- ```
+### CSS: matching by text
-- `/Log\s*in/i` - body can be a [JavaScript-like regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) wrapped in `/` symbols. For example, `text=/Log\s*in/i` matches `<button>Login</button>` and `<button>log IN</button>`.
+Playwright include a number of CSS pseudo-classes to match elements by their text content.
- ```js
- await page.locator('text=/Log\\s*in/i').click();
- ```
- ```java
- page.locator("text=/Log\\s*in/i").click();
- ```
- ```python async
- await page.locator("text=/Log\s*in/i").click()
- ```
- ```python sync
- page.locator("text=/Log\s*in/i").click()
- ```
- ```csharp
- await page.Locator("text=/Log\\s*in/i").ClickAsync();
- ```
+- `article:has-text("Playwright")` - the `:has-text()` matches any element containing specified text somewhere inside, possibly in a child or a descendant element. Matching is case-insensitive, trims whitestapce and searches for a substring.
-- `article:has-text("Playwright")` - the `:has-text()` pseudo-class can be used inside a [css] selector. It matches any element containing specified text somewhere inside, possibly in a child or a descendant element. Matching is case-insensitive, trims whitestapce and searches for a substring. For example, `article:has-text("Playwright")` matches `<article><div>Playwright</div></article>`.
+ For example, `article:has-text("Playwright")` matches `<article><div>Playwright</div></article>`.
- Note that `:has-text()` should be used together with other `css` specifiers, otherwise it will match all the elements containing specified text, including the `<body>`.
+ Note that `:has-text()` should be used together with other CSS specifiers, otherwise it will match all the elements containing specified text, including the `<body>`.
```js
// Wrong, will match many elements including <body>
await page.locator(':has-text("Playwright")').click();
@@ -141,7 +81,9 @@ Text selector has a few variations:
await page.Locator("article:has-text(\"Playwright\")").ClickAsync();
```
-- `#nav-bar :text("Home")` - the `:text()` pseudo-class can be used inside a [css] selector. It matches the smallest element containing specified text. This example is equivalent to `text=Home`, but inside the `#nav-bar` element.
+- `#nav-bar :text("Home")` - the `:text()` pseudo-class matches the smallest element containing specified text. Matching is case-insensitive, trims whitespace and searches for a substring.
+
+ For example, this will find an element with text "Home" somewhere inside the `#nav-bar` element:
```js
await page.locator('#nav-bar :text("Home")').click();
@@ -159,60 +101,28 @@ Text selector has a few variations:
await page.Locator("#nav-bar :text('Home')").ClickAsync();
```
-- `#nav-bar :text-is("Home")` - the `:text-is()` pseudo-class can be used inside a [css] selector, for strict text node match. This example is equivalent to `text="Home"` (note quotes), but inside the `#nav-bar` element.
+- `#nav-bar :text-is("Home")` - the `:text-is()` pseudo-class matches the smallest element with exact text. Exact matching is case-sensitive, trims whitespace and searches for the full string.
-* `#nav-bar :text-matches("reg?ex", "i")` - the `:text-matches()` pseudo-class can be used inside a [css] selector, for regex-based match. This example is equivalent to `text=/reg?ex/i`, but inside the `#nav-bar` element.
+ For example, `:text-is("Log")` does not match `<button>Log in</button>` because `<button>` contains a single text node `"Log in"` that is not equal to `"Log"`. However, `:text-is("Log")` matches `<button> Log <span>in</span></button>`, because `<button>` contains a text node `" Log "`.
+
+ Similarly, `:text-is("Download")` will not match `<button>download</button>` because it is case-sensitive.
+
+* `#nav-bar :text-matches("reg?ex", "i")` - the `:text-matches()` pseudo-class matches the smallest element with text content matching the [JavaScript-like regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp).
+
+ For example, `:text-matches("Log\s*in", "i")` matches `<button>Login</button>` and `<button>log IN</button>`.
:::note
-Matching always normalizes whitespace. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
+Text matching always normalizes whitespace. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
:::
:::note
-Input elements of the type `button` and `submit` are matched by their `value` instead of text content. For example, `text=Log in` matches `<input type=button value="Log in">`.
+Input elements of the type `button` and `submit` are matched by their `value` instead of text content. For example, `:text("Log in")` matches `<input type=button value="Log in">`.
:::
-## CSS selector
-
-Playwright augments standard CSS selectors in two ways:
-* `css` engine pierces open shadow DOM by default.
-* Playwright adds custom pseudo-classes like `:visible`, `:text` and more.
-
-```js
-await page.locator('button').click();
-```
-
-```java
-page.locator("button").click();
-```
-
-```python async
-await page.locator("button").click()
-```
-
-```python sync
-page.locator("button").click()
-```
-
-```csharp
-await page.Locator("button").ClickAsync();
-```
-
-## Selecting visible elements
-
-There are two ways of selecting only [visible](./actionability.md#visible) elements with Playwright:
-- `:visible` pseudo-class in CSS selectors
-- `visible=` selector engine
-If you prefer your selectors to be CSS and don't want to rely on [chaining selectors](#chaining-selectors), use `:visible` pseudo class like so: `input:visible`. If you prefer combining selector engines, use `input >> visible=true`. The latter allows you to combine `text=`, `xpath=` and other selector engines with the visibility filter.
+### CSS: matching only visible elements
-For example, `input` matches all the inputs on the page, while
-`input:visible` and `input >> visible=true` only match visible inputs. This is useful to distinguish elements
-that are very similar but differ in visibility.
-
-:::note
-It's usually better to follow the [best practices](#best-practices) and find a more reliable way to
-uniquely identify the element.
-:::
+Playwrigt supports the `:visible` pseudo class in CSS selectors. For example, `css=button` matches all the buttons on the page, while `css=button:visible` only matches visible buttons. This is useful to distinguish elements that are very similar but differ in visibility.
Consider a page with two buttons, first invisible and second visible.
@@ -221,7 +131,7 @@ Consider a page with two buttons, first invisible and second visible.
<button>Visible</button>
```
-* This will find the first button because it is the first element in DOM order. Then it will wait for the button to become visible before clicking, or timeout while waiting:
+* This will find both buttons and throw a [strictness](./locators.md#strictness) violation error:
```js
await page.locator('button').click();
@@ -243,79 +153,28 @@ Consider a page with two buttons, first invisible and second visible.
await page.Locator("button").ClickAsync();
```
-* These will find a second button, because it is visible, and then click it.
+* This will only find a second button, because it is visible, and then click it.
```js
await page.locator('button:visible').click();
- await page.locator('button >> visible=true').click();
```
```java
page.locator("button:visible").click();
- page.locator("button >> visible=true").click();
```
```python async
await page.locator("button:visible").click()
- await page.locator("button >> visible=true").click()
```
```python sync
page.locator("button:visible").click()
- page.locator("button >> visible=true").click()
```
```csharp
await page.Locator("button:visible").ClickAsync();
- await page.Locator("button >> visible=true").ClickAsync();
- ```
-
-## Selecting elements that contain other elements
-
-### Filter by text
-
-Locators support an option to only select elements that have some text somewhere inside, possibly in a descendant element. Matching is case-insensitive and searches for a substring.
-
- ```js
- await page.locator('button', { hasText: 'Click me' }).click();
- ```
- ```java
- page.locator("button", new Page.LocatorOptions().setHasText("Click me")).click();
- ```
- ```python async
- await page.locator("button", has_text="Click me").click()
- ```
- ```python sync
- page.locator("button", has_text="Click me").click()
- ```
- ```csharp
- await page.Locator("button", new() { HasText = "Click me" }).ClickAsync();
- ```
-
-You can also pass a regular expression.
-
-### Filter by another locator
-
-Locators support an option to only select elements that have a descendant matching another locator.
-
- ```js
- page.locator('article', { has: page.locator('button.subscribe') })
- ```
- ```java
- page.locator("article", new Page.LocatorOptions().setHas(page.locator("button.subscribe")))
- ```
- ```python async
- page.locator("article", has=page.locator("button.subscribe"))
- ```
- ```python sync
- page.locator("article", has=page.locator("button.subscribe"))
- ```
- ```csharp
- page.Locator("article", new() { Has = page.Locator("button.subscribe") })
```
-Note that inner locator is matched starting from the outer one, not from the document root.
-
-### Inside CSS selector
+### CSS: elements that contain other elements
The `:has()` pseudo-class is an [experimental CSS pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:has). It returns an element if any of the selectors passed as parameters
-relative to the :scope of the given element match at least one element.
+relative to the `:scope` of the given element match at least one element.
Following snippet returns text content of an `<article>` element that has a `<div class=promo>` inside.
@@ -339,39 +198,7 @@ page.locator("article:has(div.promo)").text_content()
await page.Locator("article:has(div.promo)").TextContentAsync();
```
-## Augmenting existing locators
-
-You can add filtering to any locator by passing `:scope` selector to [`method: Locator.locator`] and specifying desired options. For example, given the locator `row` that selects some rows in the table, you can filter to just those that contain text "Hello".
-
- ```js
- const row = page.locator('.row');
- // ... later on ...
- await row.locator(':scope', { hasText: 'Hello' }).click();
- ```
- ```java
- Locator row = page.locator(".row");
- // ... later on ...
- row.locator(":scope", new Locator.LocatorOptions().setHasText("Hello")).click();
- ```
- ```python async
- row = page.locator(".row")
- # ... later on ...
- await row.locator(":scope", has_text="Hello").click()
- ```
- ```python sync
- row = page.locator(".row")
- # ... later on ...
- row.locator(":scope", has_text="Hello").click()
- ```
- ```csharp
- var locator = page.Locator(".row");
- // ... later on ...
- await locator.Locator(":scope", new() { HasText = "Hello" }).ClickAsync();
- ```
-
-## Selecting elements matching one of the conditions
-
-### CSS selector list
+### CSS: elements matching one of the conditions
Comma-separated list of CSS selectors will match all elements that can be selected by
one of the selectors in that list.
@@ -404,116 +231,26 @@ await page.Locator("button:has-text(\"Log in\"), button:has-text(\"Sign in\")").
The `:is()` pseudo-class is an [experimental CSS pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:is) that
may be useful for specifying a list of extra conditions on an element.
-### XPath union
-
-Pipe operator (`|`) can be used to specify multiple selectors in XPath. It will match all
-elements that can be selected by one of the selectors in that list.
-
-```js
-// Waits for either confirmation dialog or load spinner.
-await page.locator(`//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']`).waitFor();
-```
-
-```java
-// Waits for either confirmation dialog or load spinner.
-page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").waitFor();
-```
-
-```python async
-# Waits for either confirmation dialog or load spinner.
-await page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").wait_for()
-```
-
-```python sync
-# Waits for either confirmation dialog or load spinner.
-page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").wait_for()
-```
-
-```csharp
-// Waits for either confirmation dialog or load spinner.
-await page.Locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").WaitFor();
-```
-
-## Selecting elements in Shadow DOM
-
-Our `css` and `text` engines pierce the [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) by default:
-- First they search for the elements in the light DOM in the iteration order, and
-- Then they search recursively inside open shadow roots in the iteration order.
-In particular, in `css` engine, any [Descendant combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator)
-or [Child combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator) pierces an
-arbitrary number of open shadow roots, including the implicit descendant combinator at the start of the
-selector. It does not search inside closed shadow roots or iframes.
-
-If you'd like to opt out of this behavior, you can use `:light` CSS extension or `text:light` selector engine. They do not pierce shadow roots.
-
-```js
-await page.locator(':light(.article > .header)').click();
-```
-
-```java
-page.locator(":light(.article > .header)").click();
-```
-
-```python async
-await page.locator(":light(.article > .header)").click()
-```
-
-```python sync
-page.locator(":light(.article > .header)").click()
-```
-
-```csharp
-await page.Locator(":light(.article > .header)").ClickAsync();
-```
+### CSS: matching elements based on layout
-More advanced Shadow DOM use cases:
+:::note
+Matching based on layout may produce unexpected results. For example, a different element could be matched when layout changes by one pixel.
+:::
-```html
-<article>
- <div>In the light dom</div>
- <div slot='myslot'>In the light dom, but goes into the shadow slot</div>
- #shadow-root
- <div class='in-the-shadow'>
- <span class='content'>
- In the shadow dom
- #shadow-root
- <li id='target'>Deep in the shadow</li>
- </span>
- </div>
- <slot name='myslot'></slot>
-</article>
-```
-
-- Both `"article div"` and `":light(article div)"` match the first `<div>In the light dom</div>`.
-- Both `"article > div"` and `":light(article > div)"` match two `div` elements that are direct children of the `article`.
-- `"article .in-the-shadow"` matches the `<div class='in-the-shadow'>`, piercing the shadow root, while `":light(article .in-the-shadow)"` does not match anything.
-- `":light(article div > span)"` does not match anything, because both light-dom `div` elements do not contain a `span`.
-- `"article div > span"` matches the `<span class='content'>`, piercing the shadow root.
-- `"article > .in-the-shadow"` does not match anything, because `<div class='in-the-shadow'>` is not a direct child of `article`
-- `":light(article > .in-the-shadow)"` does not match anything.
-- `"article li#target"` matches the `<li id='target'>Deep in the shadow</li>`, piercing two shadow roots.
-
-## Selecting elements based on layout
-
-Sometimes, it is hard to come up with a good selector to the target element when it lacks distinctive features. In this case, using Playwright layout selectors could help. These can be combined with regular CSS to pinpoint one of the multiple choices.
+Sometimes, it is hard to come up with a good selector to the target element when it lacks distinctive features. In this case, using Playwright layout CSS pseudo-classes could help. These can be combined with regular CSS to pinpoint one of the multiple choices.
For example, `input:right-of(:text("Password"))` matches an input field that is to the right of text "Password" - useful when the page has multiple inputs that are hard to distinguish between each other.
-Note that layout selector is useful in addition to something else, like `input`. If you use layout selector alone, like `:right-of(:text("Password"))`, most likely you'll get not the input you are looking for, but some empty element in between the text and the target input.
-
-:::note
-Layout selectors depend on the page layout and may produce unexpected results. For example, a different
-element could be matched when layout changes by one pixel.
-:::
+Note that layout pseudo-classes are useful in addition to something else, like `input`. If you use a layout pseudo-class alone, like `:right-of(:text("Password"))`, most likely you'll get not the input you are looking for, but some empty element in between the text and the target input.
-Layout selectors use [bounding client rect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)
+Layout pseudo-classes use [bounding client rect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)
to compute distance and relative position of the elements.
-* `:right-of(inner > selector)` - Matches elements that are to the right of any element matching the inner selector, at any vertical position.
-* `:left-of(inner > selector)` - Matches elements that are to the left of any element matching the inner selector, at any vertical position.
-* `:above(inner > selector)` - Matches elements that are above any of the elements matching the inner selector, at any horizontal position.
-* `:below(inner > selector)` - Matches elements that are below any of the elements matching the inner selector, at any horizontal position.
-* `:near(inner > selector)` - Matches elements that are near (within 50 CSS pixels) any of the elements matching the inner selector.
+* `:right-of(div > button)` - Matches elements that are to the right of any element matching the inner selector, at any vertical position.
+* `:left-of(div > button)` - Matches elements that are to the left of any element matching the inner selector, at any vertical position.
+* `:above(div > button)` - Matches elements that are above any of the elements matching the inner selector, at any horizontal position.
+* `:below(div > button)` - Matches elements that are below any of the elements matching the inner selector, at any horizontal position.
+* `:near(div > button)` - Matches elements that are near (within 50 CSS pixels) any of the elements matching the inner selector.
Note that resulting matches are sorted by their distance to the anchor element, so you can use [`method: Locator.first`] to pick the closest one. This is only useful if you have something like a list of similar elements, where the closest is obviously the right one. However, using [`method: Locator.first`] in other cases most likely won't work as expected - it will not target the element you are searching for, but some other element that happens to be the closest like a random empty `<div>`, or an element that is scrolled out and is not currently visible.
@@ -572,117 +309,237 @@ await page.Locator("button:near(.promo-card)").ClickAsync();
await page.Locator("[type=radio]:left-of(:text(\"Label 3\"))").First.ClickAsync();
```
-All layout selectors support optional maximum pixel distance as the last argument. For example
-`button:near(:text("Username"), 120)` matches a button that is at most 120 pixels away from the element with the text "Username".
+All layout pseudo-classes support optional maximum pixel distance as the last argument. For example
+`button:near(:text("Username"), 120)` matches a button that is at most 120 CSS pixels away from the element with the text "Username".
-## Selecting elements by label text
+### CSS: pick n-th match from the query result
-Targeted input actions in Playwright automatically distinguish between labels and controls, so you can target the label to perform an action on the associated control.
+:::note
+It is usually possible to distinguish elements by some attribute or text content, which is more resilient to page changes.
+:::
+
+Sometimes page contains a number of similar elements, and it is hard to select a particular one. For example:
+
+```html
+<section> <button>Buy</button> </section>
+<article><div> <button>Buy</button> </div></article>
+<div><div> <button>Buy</button> </div></div>
+```
-For example, consider the following DOM structure: `<label for="password">Password:</label><input id="password" type="password">`. You can target the label with something like `text=Password` and perform the following actions on the input instead:
-- `click` will click the label and automatically focus the input field;
-- `fill` will fill the input field;
-- `inputValue` will return the value of the input field;
-- `selectText` will select text in the input field;
-- `setInputFiles` will set files for the input field with `type=file`;
-- `selectOption` will select an option from the select box.
+In this case, `:nth-match(:text("Buy"), 3)` will select the third button from the snippet above. Note that index is one-based.
```js
-// Fill the input by targeting the label.
-await page.locator('text=Password').fill('secret');
+// Click the third "Buy" button
+await page.locator(':nth-match(:text("Buy"), 3)').click();
```
```java
-// Fill the input by targeting the label.
-page.locator("text=Password").fill("secret");
+// Click the third "Buy" button
+page.locator(":nth-match(:text('Buy'), 3)").click();
```
```python async
-# Fill the input by targeting the label.
-await page.locator('text=Password').fill('secret')
+# Click the third "Buy" button
+await page.locator(":nth-match(:text('Buy'), 3)").click()
```
```python sync
-# Fill the input by targeting the label.
-page.locator('text=Password').fill('secret')
+# Click the third "Buy" button
+page.locator(":nth-match(:text('Buy'), 3)").click()
```
```csharp
-// Fill the input by targeting the label.
-await page.Locator("text=Password").FillAsync("secret");
+// Click the third "Buy" button
+await page.Locator(":nth-match(:text('Buy'), 3)").ClickAsync();
+```
+
+`:nth-match()` is also useful to wait until a specified number of elements appear, using [`method: Locator.waitFor`].
+
+```js
+// Wait until all three buttons are visible
+await page.locator(':nth-match(:text("Buy"), 3)').waitFor();
```
-However, other methods will target the label itself, for example `textContent` will return the text content of the label, not the input field.
+```java
+// Wait until all three buttons are visible
+page.locator(":nth-match(:text('Buy'), 3)").waitFor();
+```
-## XPath selectors
+```python async
+# Wait until all three buttons are visible
+await page.locator(":nth-match(:text('Buy'), 3)").wait_for()
+```
-XPath selectors are equivalent to calling [`Document.evaluate`](https://developer.mozilla.org/en/docs/Web/API/Document/evaluate).
-Example: `xpath=//html/body`.
+```python sync
+# Wait until all three buttons are visible
+page.locator(":nth-match(:text('Buy'), 3)").wait_for()
+```
-Selector starting with `//` or `..` is assumed to be an xpath selector. For example, Playwright
-converts `'//html/body'` to `'xpath=//html/body'`.
+```csharp
+// Wait until all three buttons are visible
+await page.Locator(":nth-match(:text('Buy'), 3)").WaitForAsync();
+```
:::note
-`xpath` does not pierce shadow roots
+Unlike [`:nth-child()`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child), elements do not have to be siblings, they could be anywhere on the page. In the snippet above, all three buttons match `:text("Buy")` selector, and `:nth-match()` selects the third button.
:::
-## N-th element selector
-You can narrow down query to the n-th match using the `nth=` selector. Unlike CSS's nth-match, provided index is 0-based.
+## N-th element locator
+
+You can narrow down query to the n-th match using the `nth=` locator passing a zero-based index.
```js
// Click first button
-await page.locator('button >> nth=0').click();
+await page.locator('button').locator('nth=0').click();
// Click last button
-await page.locator('button >> nth=-1').click();
+await page.locator('button').locator('nth=-1').click();
```
```java
// Click first button
-page.locator("button >> nth=0").click();
+page.locator("button").locator("nth=0").click();
// Click last button
-page.locator("button >> nth=-1").click();
+page.locator("button").locator("nth=-1").click();
```
```python async
# Click first button
-await page.locator("button >> nth=0").click()
+await page.locator("button").locator("nth=0").click()
# Click last button
-await page.locator("button >> nth=-1").click()
+await page.locator("button").locator("nth=-1").click()
```
```python sync
# Click first button
-page.locator("button >> nth=0").click()
+page.locator("button").locator("nth=0").click()
# Click last button
-page.locator("button >> nth=-1").click()
+page.locator("button").locator("nth=-1").click()
```
```csharp
// Click first button
-await page.Locator("button >> nth=0").ClickAsync();
+await page.Locator("button").Locator("nth=0").ClickAsync();
// Click last button
-await page.Locator("button >> nth=-1").ClickAsync();
+await page.Locator("button").Locator("nth=-1").ClickAsync();
```
-## React selectors
-:::note
-React selectors are experimental and prefixed with `_`. The functionality might change in future.
-:::
+## Parent element locator
-React selectors allow selecting elements by their component name and property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
+The parent element could be selected with `..`, which is a short form for `xpath=..`.
-In react selectors, component names are transcribed with **CamelCase**.
+For example:
-Selector examples:
+```js
+const parentLocator = page.getByRole('button').locator('..');
+```
-- match by **component**: `_react=BookItem`
+```java
+Locator parentLocator = page.getByRole(AriaRole.BUTTON).locator("..");
+```
+
+```python async
+parent_locator = page.get_by_role("button").locator('..')
+```
+
+```python sync
+parent_locator = page.get_by_role("button").locator('..')
+```
+
+```csharp
+var parentLocator = page.GetByRole(AriaRole.Button).Locator("..");
+```
+
+
+### Locating only visible elements
+
+:::note
+It's usually better to find a [more reliable way](./locators.md#quick-guide) to uniquely identify the element instead of checking the visibility.
+:::
+
+Consider a page with two buttons, first invisible and second [visible](./actionability.md#visible).
+
+```html
+<button style='display: none'>Invisible</button>
+<button>Visible</button>
+```
+
+* This will find both buttons and throw a [strictness](./locators.md#strictness) violation error:
+
+ ```js
+ await page.locator('button').click();
+ ```
+
+ ```java
+ page.locator("button").click();
+ ```
+
+ ```python async
+ await page.locator("button").click()
+ ```
+
+ ```python sync
+ page.locator("button").click()
+ ```
+
+ ```csharp
+ await page.Locator("button").ClickAsync();
+ ```
+
+* This will only find a second button, because it is visible, and then click it.
+
+ ```js
+ await page.locator('button').locator('visible=true').click();
+ ```
+ ```java
+ page.locator("button").locator("visible=true").click();
+ ```
+ ```python async
+ await page.locator("button").locator("visible=true").click()
+ ```
+ ```python sync
+ page.locator("button").locator("visible=true").click()
+ ```
+ ```csharp
+ await page.Locator("button").Locator("visible=true").ClickAsync();
+ ```
+
+
+## React locator
+
+:::note
+React locator is experimental and prefixed with `_`. The functionality might change in future.
+:::
+
+React locator allows finding elements by their component name and property values. The syntax is very similar to [CSS attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all CSS attribute selector operators.
+
+In React locator, component names are transcribed with **CamelCase**.
+
+```js
+await page.locator('_react=BookItem').click();
+```
+```java
+page.locator("_react=BookItem").click();
+```
+```python async
+await page.locator("_react=BookItem").click()
+```
+```python sync
+page.locator("_react=BookItem").click()
+```
+```csharp
+await page.Locator("_react=BookItem").ClickAsync();
+```
+
+More examples:
+
+- match by **component**: `_react=BookItem`
- match by component and **exact property value**, case-sensitive: `_react=BookItem[author = "Steven King"]`
- match by property value only, **case-insensitive**: `_react=[author = "steven king" i]`
- match by component and **truthy property value**: `_react=MyButton[enabled]`
@@ -700,24 +557,40 @@ To find React element names in a tree use [React DevTools](https://chrome.google
:::note
-React selectors support React 15 and above.
+React locator supports React 15 and above.
:::
:::note
-React selectors, as well as [React DevTools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), only work against **unminified** application builds.
+React locator, as well as [React DevTools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), only work against **unminified** application builds.
:::
-## Vue selectors
+## Vue locator
:::note
-Vue selectors are experimental and prefixed with `_`. The functionality might change in future.
+Vue locator is experimental and prefixed with `_`. The functionality might change in future.
:::
-Vue selectors allow selecting elements by their component name and property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
+Vue locator allows finding elements by their component name and property values. The syntax is very similar to [CSS attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all CSS attribute selector operators.
-In Vue selectors, component names are transcribed with **kebab-case**.
+In Vue locator, component names are transcribed with **kebab-case**.
-Selector examples:
+```js
+await page.locator('_vue=book-item').click();
+```
+```java
+page.locator("_vue=book-item").click();
+```
+```python async
+await page.locator("_vue=book-item").click()
+```
+```python sync
+page.locator("_vue=book-item").click()
+```
+```csharp
+await page.Locator("_vue=book-item").ClickAsync();
+```
+
+More examples:
- match by **component**: `_vue=book-item`
- match by component and **exact property value**, case-sensitive: `_vue=book-item[author = "Steven King"]`
@@ -734,240 +607,313 @@ Selector examples:
To find Vue element names in a tree use [Vue DevTools](https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd?hl=en).
:::note
-Vue selectors support Vue2 and above.
+Vue locator supports Vue2 and above.
:::
:::note
-Vue selectors, as well as [Vue DevTools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), only work against **unminified** application builds.
+Vue locator, as well as [Vue DevTools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), only work against **unminified** application builds.
:::
-## Role selector
-
-Role selector allows selecting elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Note that role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.
-
-The syntax is very similar to [CSS attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors). For example, `role=button[name="Click me"][pressed]` selects a pressed button that has accessible name "Click me".
-
-Note that many html elements have an implicitly [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
-
-Attributes supported by the role selector:
-* `checked` - an attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls. Available values for checked are `true`, `false` and `"mixed"`. Examples:
- - `role=checkbox[checked=true]`, equivalent to `role=checkbox[checked]`
- - `role=checkbox[checked=false]`
- - `role=checkbox[checked="mixed"]`
+## XPath locator
- Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
-
-* `disabled` - a boolean attribute that is usually set by `aria-disabled` or `disabled`. Examples:
- - `role=button[disabled=true]`, equivalent to `role=button[disabled]`
- - `role=button[disabled=false]`
-
- Note that unlike most other attributes, `disabled` is inherited through the DOM hierarchy.
- Learn more about [`aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled).
+:::warning
+We recommend prioritzing [user-visible locators](./locators.md#quick-guide) like text or accessible role instead of using XPath that is tied to the implementation and easily break when the page changes.
+:::
-* `expanded` - a boolean attribute that is usually set by `aria-expanded`. Examples:
- - `role=button[expanded=true]`, equivalent to `role=button[expanded]`
- - `role=button[expanded=false]`
+XPath locators are equivalent to calling [`Document.evaluate`](https://developer.mozilla.org/en/docs/Web/API/Document/evaluate).
- Learn more about [`aria-expanded`](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded).
+```js
+await page.locator('xpath=//button').click();
+```
+```java
+page.locator("xpath=//button").click();
+```
+```python async
+await page.locator("xpath=//button").click()
+```
+```python sync
+page.locator("xpath=//button").click()
+```
+```csharp
+await page.Locator("xpath=//button").ClickAsync();
+```
-* `include-hidden` - a boolean attribute that controls whether hidden elements are matched. By default, only non-hidden elements, as [defined by ARIA](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion), are matched by role selector. With `[include-hidden]`, both hidden and non-hidden elements are matched. Examples:
- - `role=button[include-hidden=true]`, equivalent to `role=button[include-hidden]`
- - `role=button[include-hidden=false]`
+:::note
+Any selector string starting with `//` or `..` are assumed to be an xpath selector. For example, Playwright converts `'//html/body'` to `'xpath=//html/body'`.
+:::
- Learn more about [`aria-hidden`](https://www.w3.org/TR/wai-aria-1.2/#aria-hidden).
+:::note
+XPath does not pierce shadow roots.
+:::
-* `level` - a number attribute that is usually present for roles `heading`, `listitem`, `row`, `treeitem`, with default values for `<h1>-<h6>` elements. Examples:
- - `role=heading[level=1]`
- Learn more about [`aria-level`](https://www.w3.org/TR/wai-aria-1.2/#aria-level).
+### XPath union
-* `name` - a string attribute that matches [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). Supports attribute operators like `=` and `*=`, and regular expressions.
- - `role=button[name="Click me"]`
- - `role=button[name*="Click"]`
- - `role=button[name=/Click( me)?/]`
+Pipe operator (`|`) can be used to specify multiple selectors in XPath. It will match all
+elements that can be selected by one of the selectors in that list.
- Learn more about [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
+```js
+// Waits for either confirmation dialog or load spinner.
+await page.locator(`//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']`).waitFor();
+```
-* `pressed` - an attribute that is usually set by `aria-pressed`. Available values for pressed are `true`, `false` and `"mixed"`. Examples:
- - `role=button[pressed=true]`, equivalent to `role=button[pressed]`
- - `role=button[pressed=false]`
- - `role=button[pressed="mixed"]`
+```java
+// Waits for either confirmation dialog or load spinner.
+page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").waitFor();
+```
- Learn more about [`aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).
+```python async
+# Waits for either confirmation dialog or load spinner.
+await page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").wait_for()
+```
-* `selected` - a boolean attribute that is usually set by `aria-selected`. Examples:
- - `role=option[selected=true]`, equivalent to `role=option[selected]`
- - `role=option[selected=false]`
+```python sync
+# Waits for either confirmation dialog or load spinner.
+page.locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").wait_for()
+```
- Learn more about [`aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected).
+```csharp
+// Waits for either confirmation dialog or load spinner.
+await page.Locator("//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']").WaitForAsync();
+```
-Examples:
-* `role=button` matches all buttons;
-* `role=button[name="Click me"]` matches buttons with "Click me" accessible name;
-* `role=checkbox[checked][include-hidden]` matches checkboxes that are checked, including those that are currently hidden.
+## Label to form control retargeting
-## id, data-testid, data-test-id, data-test selectors
+:::warning
+We recommend [locating by label text](./locators.md#locate-by-label) instead of relying to label-to-control retargeting.
+:::
-Playwright supports shorthand for selecting elements using certain attributes. Currently, only
-the following attributes are supported:
+Targeted input actions in Playwright automatically distinguish between labels and controls, so you can target the label to perform an action on the associated control.
-- `id`
-- `data-testid`
-- `data-test-id`
-- `data-test`
+For example, consider the following DOM structure: `<label for="password">Password:</label><input id="password" type="password">`. You can target the label by it's "Password" text using [`method: Page.getByText`]. However, the following actions will be performed on the input instead of the label:
+- [`method: Locator.click`] will click the label and automatically focus the input field;
+- [`method: Locator.fill`] will fill the input field;
+- [`method: Locator.inputValue`] will return the value of the input field;
+- [`method: Locator.selectText`] will select text in the input field;
+- [`method: Locator.setInputFiles`] will set files for the input field with `type=file`;
+- [`method: Locator.selectOption`] will select an option from the select box.
```js
-// Fill an input with the id "username"
-await page.locator('id=username').fill('value');
-
-// Click an element with data-test-id "submit"
-await page.locator('data-test-id=submit').click();
+// Fill the input by targeting the label.
+await page.getByText('Password').fill('secret');
```
```java
-// Fill an input with the id "username"
-page.locator("id=username").fill("value");
-
-// Click an element with data-test-id "submit"
-page.locator("data-test-id=submit").click();
+// Fill the input by targeting the label.
+page.getByText("Password").fill("secret");
```
```python async
-# Fill an input with the id "username"
-await page.locator('id=username').fill('value')
-
-# Click an element with data-test-id "submit"
-await page.locator('data-test-id=submit').click()
+# Fill the input by targeting the label.
+await page.get_by_text("Password").fill("secret")
```
```python sync
-# Fill an input with the id "username"
-page.locator('id=username').fill('value')
-
-# Click an element with data-test-id "submit"
-page.locator('data-test-id=submit').click()
+# Fill the input by targeting the label.
+page.get_by_text("Password").fill("secret")
```
```csharp
-// Fill an input with the id "username"
-await page.Locator("id=username").FillAsync("value");
-
-// Click an element with data-test-id "submit"
-await page.Locator("data-test-id=submit").ClickAsync();
+// Fill the input by targeting the label.
+await page.GetByText("Password").FillAsync("secret");
```
-:::note
-Attribute selectors are not CSS selectors, so anything CSS-specific like `:enabled` is not supported. For more features, use a proper [css] selector, e.g. `css=[data-test="login"]:enabled`.
-:::
+However, other methods will target the label itself, for example [`method: LocatorAssertions.toHaveText`] will assert the text content of the label, not the input field.
-:::note
-Attribute selectors pierce shadow DOM. To opt-out from this behavior, use `:light` suffix after attribute, for example `page.locator('data-test-id:light=submit').click()`
-:::
-
-
-## Pick n-th match from the query result
-
-Sometimes page contains a number of similar elements, and it is hard to select a particular one. For example:
-
-```html
-<section> <button>Buy</button> </section>
-<article><div> <button>Buy</button> </div></article>
-<div><div> <button>Buy</button> </div></div>
-```
-
-In this case, `:nth-match(:text("Buy"), 3)` will select the third button from the snippet above. Note that index is one-based.
```js
-// Click the third "Buy" button
-await page.locator(':nth-match(:text("Buy"), 3)').click();
+// Fill the input by targeting the label.
+await expect(page.locator('label')).toHaveText('Password');
```
```java
-// Click the third "Buy" button
-page.locator(":nth-match(:text('Buy'), 3)").click();
+// Fill the input by targeting the label.
+assertThat(page.locator("label")).hasText("Password");
```
```python async
-# Click the third "Buy" button
-await page.locator(":nth-match(:text('Buy'), 3)").click()
+# Fill the input by targeting the label.
+await expect(page.locator("label")).to_have_text("Password")
```
```python sync
-# Click the third "Buy" button
-page.locator(":nth-match(:text('Buy'), 3)").click()
+# Fill the input by targeting the label.
+expect(page.locator("label")).to_have_text("Password")
```
```csharp
-// Click the third "Buy" button
-await page.Locator(":nth-match(:text('Buy'), 3)").ClickAsync();
+// Fill the input by targeting the label.
+await Expect(page.Locator("label")).ToHaveTextAsync("Password");
```
-`:nth-match()` is also useful to wait until a specified number of elements appear, using [`method: Locator.waitFor`].
+## Legacy text locator
+
+:::warning
+We recommend the modern [text locator](./locators.md#get-by-text) instead.
+:::
+
+Legacy text locator matches elements that contain passed text.
```js
-// Wait until all three buttons are visible
-await page.locator(':nth-match(:text("Buy"), 3)').waitFor();
+await page.locator('text=Log in').click();
```
-
```java
-// Wait until all three buttons are visible
-page.locator(":nth-match(:text('Buy'), 3)").waitFor();
+page.locator("text=Log in").click();
```
-
```python async
-# Wait until all three buttons are visible
-await page.locator(":nth-match(:text('Buy'), 3)").wait_for()
+await page.locator("text=Log in").click()
```
-
```python sync
-# Wait until all three buttons are visible
-page.locator(":nth-match(:text('Buy'), 3)").wait_for()
+page.locator("text=Log in").click()
```
-
```csharp
-// Wait until all three buttons are visible
-await page.Locator(":nth-match(:text('Buy'), 3)").WaitForAsync();
+await page.Locator("text=Log in").ClickAsync();
```
+Legacy text locator has a few variations:
+
+- `text=Log in` - default matching is case-insensitive, trims whitespace and searches for a substring. For example, `text=Log` matches `<button>Log in</button>`.
+
+ ```js
+ await page.locator('text=Log in').click();
+ ```
+ ```java
+ page.locator("text=Log in").click();
+ ```
+ ```python async
+ await page.locator("text=Log in").click()
+ ```
+ ```python sync
+ page.locator("text=Log in").click()
+ ```
+ ```csharp
+ await page.Locator("text=Log in").ClickAsync();
+ ```
+
+- `text="Log in"` - text body can be escaped with single or double quotes to search for a text node with exact content after trimming whitespace.
+
+ For example, `text="Log"` does not match `<button>Log in</button>` because `<button>` contains a single text node `"Log in"` that is not equal to `"Log"`. However, `text="Log"` matches `<button> Log <span>in</span></button>`, because `<button>` contains a text node `" Log "`. This exact mode implies case-sensitive matching, so `text="Download"` will not match `<button>download</button>`.
+
+ Quoted body follows the usual escaping rules, e.g. use `\"` to escape double quote in a double-quoted string: `text="foo\"bar"`.
+
+ ```js
+ await page.locator('text="Log in"').click();
+ ```
+ ```java
+ page.locator("text='Log in'").click();
+ ```
+ ```python async
+ await page.locator("text='Log in'").click()
+ ```
+ ```python sync
+ page.locator("text='Log in'").click()
+ ```
+ ```csharp
+ await page.Locator("text='Log in'").ClickAsync();
+ ```
+
+- `/Log\s*in/i` - body can be a [JavaScript-like regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) wrapped in `/` symbols. For example, `text=/Log\s*in/i` matches `<button>Login</button>` and `<button>log IN</button>`.
+
+ ```js
+ await page.locator('text=/Log\\s*in/i').click();
+ ```
+ ```java
+ page.locator("text=/Log\\s*in/i").click();
+ ```
+ ```python async
+ await page.locator("text=/Log\s*in/i").click()
+ ```
+ ```python sync
+ page.locator("text=/Log\s*in/i").click()
+ ```
+ ```csharp
+ await page.Locator("text=/Log\\s*in/i").ClickAsync();
+ ```
+
:::note
-Unlike [`:nth-child()`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child), elements do not have to be siblings, they could be anywhere on the page. In the snippet above, all three buttons match `:text("Buy")` selector, and `:nth-match()` selects the third button.
+String selectors starting and ending with a quote (either `"` or `'`) are assumed to be a legacy text locators. For example, `"Log in"` is converted to `text="Log in"` internally.
:::
:::note
-It is usually possible to distinguish elements by some attribute or text content. In this case,
-prefer using [text] or [css] selectors over the `:nth-match()`.
+Matching always normalizes whitespace. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.
:::
-## Parent selector
+:::note
+Input elements of the type `button` and `submit` are matched by their `value` instead of text content. For example, `text=Log in` matches `<input type=button value="Log in">`.
+:::
-The parent could be selected with `..`, which is a short form for `xpath=..`.
-For example:
+## id, data-testid, data-test-id, data-test selectors
+
+:::warning
+We recommend [locating by test id](./locators.md#locate-by-test-id) instead.
+:::
+
+Playwright supports shorthand for selecting elements using certain attributes. Currently, only
+the following attributes are supported:
+
+- `id`
+- `data-testid`
+- `data-test-id`
+- `data-test`
```js
-const parentLocator = elementLocator.locator('..');
+// Fill an input with the id "username"
+await page.locator('id=username').fill('value');
+
+// Click an element with data-test-id "submit"
+await page.locator('data-test-id=submit').click();
```
```java
-Locator parentLocator = elementLocator.locator("..");
+// Fill an input with the id "username"
+page.locator("id=username").fill("value");
+
+// Click an element with data-test-id "submit"
+page.locator("data-test-id=submit").click();
```
```python async
-parent_locator = element_locator.locator('..')
+# Fill an input with the id "username"
+await page.locator('id=username').fill('value')
+
+# Click an element with data-test-id "submit"
+await page.locator('data-test-id=submit').click()
```
```python sync
-parent_locator = element_locator.locator('..')
+# Fill an input with the id "username"
+page.locator('id=username').fill('value')
+
+# Click an element with data-test-id "submit"
+page.locator('data-test-id=submit').click()
```
```csharp
-var parentLocator = elementLocator.Locator("..");
+// Fill an input with the id "username"
+await page.Locator("id=username").FillAsync("value");
+
+// Click an element with data-test-id "submit"
+await page.Locator("data-test-id=submit").ClickAsync();
```
+:::note
+Attribute selectors are not CSS selectors, so anything CSS-specific like `:enabled` is not supported. For more features, use a proper [css] selector, e.g. `css=[data-test="login"]:enabled`.
+:::
+
+:::note
+Attribute selectors pierce shadow DOM. To opt-out from this behavior, use `:light` suffix after attribute, for example `page.locator('data-test-id:light=submit').click()`
+:::
+
+
## Chaining selectors
+:::warning
+We recommend [chaining locators](./locators.md#chaining-locators) instead.
+:::
+
Selectors defined as `engine=body` or in short-form can be combined with the `>>` token, e.g. `selector1 >> selector2 >> selectors3`. When selectors are chained, the next one is queried relative to the previous one's result.
For example,
@@ -987,6 +933,10 @@ If a selector needs to include `>>` in the body, it should be escaped inside a s
### Intermediate matches
+:::warning
+We recommend [filtering by another locator](./locators.md#filter-by-another-locator) to locate elements that contain other elements.
+:::
+
By default, chained selectors resolve to an element queried by the last selector. A selector can be prefixed with `*` to capture elements that are queried by an intermediate selector.
For example, `css=article >> text=Hello` captures the element with the text `Hello`, and `*css=article >> text=Hello` (note the `*`) captures the `article` element that contains some element with the text `Hello`.
diff --git a/docs/src/protractor-js.md b/docs/src/protractor-js.md
index 7beb2913c7..16707900b9 100644
--- a/docs/src/protractor-js.md
+++ b/docs/src/protractor-js.md
@@ -162,8 +162,7 @@ Learn more about Playwright Test runner:
- [Getting Started](./intro)
- [Fixtures](./test-fixtures)
-- [Locators](./api/class-locator)
-- [Selectors](./selectors)
+- [Locators](./locators)
- [Assertions](./test-assertions)
- [Auto-waiting](./actionability)
diff --git a/docs/src/puppeteer-js.md b/docs/src/puppeteer-js.md
index a03f0d278d..9ec95b063d 100644
--- a/docs/src/puppeteer-js.md
+++ b/docs/src/puppeteer-js.md
@@ -172,7 +172,6 @@ Learn more about Playwright Test runner:
- [Getting Started](./intro)
- [Fixtures](./test-fixtures)
-- [Locators](./api/class-locator)
-- [Selectors](./selectors)
+- [Locators](./locators.md)
- [Assertions](./test-assertions)
- [Auto-waiting](./actionability)
diff --git a/docs/src/release-notes-csharp.md b/docs/src/release-notes-csharp.md
index 93515af0ee..9f9aad235b 100644
--- a/docs/src/release-notes-csharp.md
+++ b/docs/src/release-notes-csharp.md
@@ -317,7 +317,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
await page.Locator("role=button[name='log in']").ClickAsync();
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New [`method: Locator.filter`] API to filter an existing locator
@@ -339,7 +339,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
await page.Locator("role=button[name='log in']").ClickAsync();
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New `scale` option in [`method: Page.screenshot`] for smaller sized screenshots.
- New `caret` option in [`method: Page.screenshot`] to control text caret. Defaults to `"hide"`.
- We now ship a designated .NET docker image `mcr.microsoft.com/playwright/dotnet`. Read more in [our documentation](./docker).
@@ -628,7 +628,7 @@ await locator.ClickAsync();
Learn more in the [documentation](./api/class-locator).
-#### 🧩 Experimental [**React**](./selectors#react-selectors) and [**Vue**](./selectors#vue-selectors) selector engines
+#### 🧩 Experimental [**React**](./other-locators.md#react-locator) and [**Vue**](./other-locators.md#vue-locator) selector engines
React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
@@ -637,12 +637,12 @@ await page.Locator("_react=SubmitButton[enabled=true]").ClickAsync();
await page.Locator("_vue=submit-button[enabled=true]").ClickAsync();
```
-Learn more in the [react selectors documentation](./selectors#react-selectors) and the [vue selectors documentation](./selectors#vue-selectors).
+Learn more in the [react selectors documentation](./other-locators.md#react-locator) and the [vue selectors documentation](./other-locators.md#vue-locator).
-#### ✨ New [**`nth`**](./selectors#n-th-element-selector) and [**`visible`**](./selectors#selecting-visible-elements) selector engines
+#### ✨ New [**`nth`**](./other-locators.md#n-th-element-locator) and [**`visible`**](./other-locators.md#css-matching-only-visible-elements) selector engines
-- [`nth`](./selectors#n-th-element-selector) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
-- [`visible`](./selectors#selecting-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
+- [`nth`](./other-locators.md#n-th-element-locator) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
+- [`visible`](./other-locators.md#css-matching-only-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
```csharp
// select the first button among all buttons
diff --git a/docs/src/release-notes-java.md b/docs/src/release-notes-java.md
index 5025f2bf7b..84e1c42917 100644
--- a/docs/src/release-notes-java.md
+++ b/docs/src/release-notes-java.md
@@ -257,7 +257,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
page.locator("role=button[name='log in']").click();
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New [`method: Locator.filter`] API to filter an existing locator
@@ -283,7 +283,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
page.locator("role=button[name='log in']").click();
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New `scale` option in [`method: Page.screenshot`] for smaller sized screenshots.
- New `caret` option in [`method: Page.screenshot`] to control text caret. Defaults to `"hide"`.
@@ -590,7 +590,7 @@ locator.click();
Learn more in the [documentation](./api/class-locator).
-#### 🧩 Experimental [**React**](./selectors#react-selectors) and [**Vue**](./selectors#vue-selectors) selector engines
+#### 🧩 Experimental [**React**](./other-locators.md#react-locator) and [**Vue**](./other-locators.md#vue-locator) selector engines
React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
@@ -599,12 +599,12 @@ page.locator("_react=SubmitButton[enabled=true]").click();
page.locator("_vue=submit-button[enabled=true]").click();
```
-Learn more in the [react selectors documentation](./selectors#react-selectors) and the [vue selectors documentation](./selectors#vue-selectors).
+Learn more in the [react selectors documentation](./other-locators.md#react-locator) and the [vue selectors documentation](./other-locators.md#vue-locator).
-#### ✨ New [**`nth`**](./selectors#n-th-element-selector) and [**`visible`**](./selectors#selecting-visible-elements) selector engines
+#### ✨ New [**`nth`**](./other-locators.md#n-th-element-locator) and [**`visible`**](./other-locators.md#css-matching-only-visible-elements) selector engines
-- [`nth`](./selectors#n-th-element-selector) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
-- [`visible`](./selectors#selecting-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
+- [`nth`](./other-locators.md#n-th-element-locator) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
+- [`visible`](./other-locators.md#css-matching-only-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
```java
// select the first button among all buttons
@@ -777,7 +777,7 @@ This version of Playwright was also tested against the following stable channels
- **Pause script execution** with [`method: Page.pause`] in headed mode. Pausing the page launches [Playwright Inspector](./debug.md) for debugging.
-- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./selectors.md#text-selector).
+- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./other-locators.md#css-matching-by-text).
- **Page dialogs are now auto-dismissed** during execution, unless a listener for `dialog` event is configured. [Learn more](./dialogs.md) about this.
@@ -795,7 +795,7 @@ This version of Playwright was also tested against the following stable channels
## Version 1.8
-- [Selecting elements based on layout](./selectors.md#selecting-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
+- [Selecting elements based on layout](./other-locators.md#css-matching-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
- Playwright now includes [command line interface](./cli.md), former playwright-cli.
```bash java
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="--help"
@@ -829,7 +829,7 @@ This version of Playwright was also tested against the following stable channels
- **New Java SDK**: [Playwright for Java](https://github.com/microsoft/playwright-java) is now on par with [JavaScript](https://github.com/microsoft/playwright), [Python](https://github.com/microsoft/playwright-python) and [.NET bindings](https://github.com/microsoft/playwright-dotnet).
- **Browser storage API**: New convenience APIs to save and load browser storage state (cookies, local storage) to simplify automation scenarios with authentication.
-- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./selectors.md) and there's more coming soon.
+- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./other-locators.md#css-locator) and there's more coming soon.
- **New website**: The docs website at [playwright.dev](https://playwright.dev/) has been updated and is now built with [Docusaurus](https://v2.docusaurus.io/).
- **Support for Apple Silicon**: Playwright browser binaries for WebKit and Chromium are now built for Apple Silicon.
diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md
index e03e67b82c..1803f1f72c 100644
--- a/docs/src/release-notes-js.md
+++ b/docs/src/release-notes-js.md
@@ -526,7 +526,7 @@ WebServer is now considered "ready" if request to the specified port has any of
await page.locator('role=button[name="log in"]').click()
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New [`method: Locator.filter`] API to filter an existing locator
@@ -568,7 +568,7 @@ WebServer is now considered "ready" if request to the specified port has any of
await page.locator('role=button[name="log in"]').click()
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New `scale` option in [`method: Page.screenshot`] for smaller sized screenshots.
- New `caret` option in [`method: Page.screenshot`] to control text caret. Defaults to `"hide"`.
@@ -1160,7 +1160,7 @@ await locator.click();
Learn more in the [documentation](./api/class-locator).
-#### 🧩 Experimental [**React**](./selectors#react-selectors) and [**Vue**](./selectors#vue-selectors) selector engines
+#### 🧩 Experimental [**React**](./other-locators.md#react-locator) and [**Vue**](./other-locators.md#vue-locator) selector engines
React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
@@ -1169,12 +1169,12 @@ await page.locator('_react=SubmitButton[enabled=true]').click();
await page.locator('_vue=submit-button[enabled=true]').click();
```
-Learn more in the [react selectors documentation](./selectors#react-selectors) and the [vue selectors documentation](./selectors#vue-selectors).
+Learn more in the [react selectors documentation](./other-locators.md#react-locator) and the [vue selectors documentation](./other-locators.md#vue-locator).
-#### ✨ New [**`nth`**](./selectors#n-th-element-selector) and [**`visible`**](./selectors#selecting-visible-elements) selector engines
+#### ✨ New [**`nth`**](./other-locators.md#n-th-element-locator) and [**`visible`**](./other-locators.md#css-matching-only-visible-elements) selector engines
-- [`nth`](./selectors#n-th-element-selector) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
-- [`visible`](./selectors#selecting-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
+- [`nth`](./other-locators.md#n-th-element-locator) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
+- [`visible`](./other-locators.md#css-matching-only-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
```js
// select the first button among all buttons
@@ -1481,7 +1481,7 @@ This version of Playwright was also tested against the following stable channels
- **Pause script execution** with [`method: Page.pause`] in headed mode. Pausing the page launches [Playwright Inspector](./debug.md) for debugging.
-- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./selectors.md#text-selector).
+- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./other-locators.md#css-matching-by-text).
- **Page dialogs are now auto-dismissed** during execution, unless a listener for `dialog` event is configured. [Learn more](./dialogs.md) about this.
@@ -1499,7 +1499,7 @@ This version of Playwright was also tested against the following stable channels
## Version 1.8
-- [Selecting elements based on layout](./selectors.md#selecting-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
+- [Selecting elements based on layout](./other-locators.md#css-matching-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
- Playwright now includes [command line interface](./cli.md), former playwright-cli.
```bash js
npx playwright --help
@@ -1533,7 +1533,7 @@ This version of Playwright was also tested against the following stable channels
- **New Java SDK**: [Playwright for Java](https://github.com/microsoft/playwright-java) is now on par with [JavaScript](https://github.com/microsoft/playwright), [Python](https://github.com/microsoft/playwright-python) and [.NET bindings](https://github.com/microsoft/playwright-dotnet).
- **Browser storage API**: New convenience APIs to save and load browser storage state (cookies, local storage) to simplify automation scenarios with authentication.
-- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./selectors.md) and there's more coming soon.
+- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./other-locators.md#css-locator) and there's more coming soon.
- **New website**: The docs website at [playwright.dev](https://playwright.dev/) has been updated and is now built with [Docusaurus](https://v2.docusaurus.io/).
- **Support for Apple Silicon**: Playwright browser binaries for WebKit and Chromium are now built for Apple Silicon.
diff --git a/docs/src/release-notes-python.md b/docs/src/release-notes-python.md
index d41874413b..a3c3bbcc91 100644
--- a/docs/src/release-notes-python.md
+++ b/docs/src/release-notes-python.md
@@ -302,7 +302,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
page.locator("role=button[name='log in']").click()
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New [`method: Locator.filter`] API to filter an existing locator
@@ -335,7 +335,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon
page.locator("role=button[name='log in']").click()
```
- Read more in [our documentation](./selectors#role-selector).
+ Read more in [our documentation](./locators.md#locate-by-role).
- New `scale` option in [`method: Page.screenshot`] for smaller sized screenshots.
- New `caret` option in [`method: Page.screenshot`] to control text caret. Defaults to `"hide"`.
@@ -663,7 +663,7 @@ locator.click()
Learn more in the [documentation](./api/class-locator).
-#### 🧩 Experimental [**React**](./selectors#react-selectors) and [**Vue**](./selectors#vue-selectors) selector engines
+#### 🧩 Experimental [**React**](./other-locators.md#react-locator) and [**Vue**](./other-locators.md#vue-locator) selector engines
React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to [attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) and supports all attribute selector operators.
@@ -672,12 +672,12 @@ page.locator("_react=SubmitButton[enabled=true]").click()
page.locator("_vue=submit-button[enabled=true]").click()
```
-Learn more in the [react selectors documentation](./selectors#react-selectors) and the [vue selectors documentation](./selectors#vue-selectors).
+Learn more in the [react selectors documentation](./other-locators.md#react-locator) and the [vue selectors documentation](./other-locators.md#vue-locator).
-#### ✨ New [**`nth`**](./selectors#n-th-element-selector) and [**`visible`**](./selectors#selecting-visible-elements) selector engines
+#### ✨ New [**`nth`**](./other-locators.md#n-th-element-locator) and [**`visible`**](./other-locators.md#css-matching-only-visible-elements) selector engines
-- [`nth`](./selectors#n-th-element-selector) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
-- [`visible`](./selectors#selecting-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
+- [`nth`](./other-locators.md#n-th-element-locator) selector engine is equivalent to the `:nth-match` pseudo class, but could be combined with other selector engines.
+- [`visible`](./other-locators.md#css-matching-only-visible-elements) selector engine is equivalent to the `:visible` pseudo class, but could be combined with other selector engines.
```py
# select the first button among all buttons
@@ -848,7 +848,7 @@ This version of Playwright was also tested against the following stable channels
- **Pause script execution** with [`method: Page.pause`] in headed mode. Pausing the page launches [Playwright Inspector](./debug.md) for debugging.
-- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./selectors.md#text-selector).
+- **New has-text pseudo-class** for CSS selectors. `:has-text("example")` matches any element containing `"example"` somewhere inside, possibly in a child or a descendant element. See [more examples](./other-locators.md#css-matching-by-text).
- **Page dialogs are now auto-dismissed** during execution, unless a listener for `dialog` event is configured. [Learn more](./dialogs.md) about this.
@@ -866,7 +866,7 @@ This version of Playwright was also tested against the following stable channels
## Version 1.8
-- [Selecting elements based on layout](./selectors.md#selecting-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
+- [Selecting elements based on layout](./other-locators.md#css-matching-elements-based-on-layout) with `:left-of()`, `:right-of()`, `:above()` and `:below()`.
- Playwright now includes [command line interface](./cli.md), former playwright-cli.
```bash python
playwright --help
@@ -900,7 +900,7 @@ This version of Playwright was also tested against the following stable channels
- **New Java SDK**: [Playwright for Java](https://github.com/microsoft/playwright-java) is now on par with [JavaScript](https://github.com/microsoft/playwright), [Python](https://github.com/microsoft/playwright-python) and [.NET bindings](https://github.com/microsoft/playwright-dotnet).
- **Browser storage API**: New convenience APIs to save and load browser storage state (cookies, local storage) to simplify automation scenarios with authentication.
-- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./selectors.md) and there's more coming soon.
+- **New CSS selectors**: We heard your feedback for more flexible selectors and have revamped the selectors implementation. Playwright 1.7 introduces [new CSS extensions](./other-locators.md#css-locator) and there's more coming soon.
- **New website**: The docs website at [playwright.dev](https://playwright.dev/) has been updated and is now built with [Docusaurus](https://v2.docusaurus.io/).
- **Support for Apple Silicon**: Playwright browser binaries for WebKit and Chromium are now built for Apple Silicon.
diff --git a/docs/src/running-tests-csharp.md b/docs/src/running-tests-csharp.md
index b5129b2042..4a1c9cf7b6 100644
--- a/docs/src/running-tests-csharp.md
+++ b/docs/src/running-tests-csharp.md
@@ -36,7 +36,7 @@ You can run a single test, a set of tests or all tests. Tests can be run on diff
```
- Running Tests on multiple browsers
-
+
To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. There you can then either specify the `BROWSER` environment variable or set the `Playwright.BrowserName` via the runsettings file:
```bash
@@ -58,7 +58,7 @@ For more information see [selective unit tests](https://docs.microsoft.com/en-us
## Debugging Tests
-Since Playwright runs in .NET, you can debug it with your debugger of choice in e.g. Visual Studio Code or Visual Studio. Playwright comes with the Playwright Inspector which allows you to step through Playwright API calls, see their debug logs and explore [selectors](./selectors.md).
+Since Playwright runs in .NET, you can debug it with your debugger of choice in e.g. Visual Studio Code or Visual Studio. Playwright comes with the Playwright Inspector which allows you to step through Playwright API calls, see their debug logs and explore [locators](./locators.md).
```bash tab=bash-bash lang=csharp
PWDEBUG=1 dotnet test
diff --git a/docs/src/running-tests-js.md b/docs/src/running-tests-js.md
index eaedb24440..6e6e7fd886 100644
--- a/docs/src/running-tests-js.md
+++ b/docs/src/running-tests-js.md
@@ -61,7 +61,7 @@ For a better debugging experience check out the [VS Code Extension](./getting-st
## Debugging Tests
-Since Playwright runs in Node.js, you can debug it with your debugger of choice e.g. using `console.log` or inside your IDE or directly in VS Code with the [VS Code Extension](./getting-started-vscode.md). Playwright comes with the [Playwright Inspector](./debug.md#playwright-inspector) which allows you to step through Playwright API calls, see their debug logs and explore [selectors](./selectors.md).
+Since Playwright runs in Node.js, you can debug it with your debugger of choice e.g. using `console.log` or inside your IDE or directly in VS Code with the [VS Code Extension](./getting-started-vscode.md). Playwright comes with the [Playwright Inspector](./debug.md#playwright-inspector) which allows you to step through Playwright API calls, see their debug logs and explore [locators](./locators.md).
- Debugging all tests:
@@ -98,7 +98,7 @@ npx playwright show-report
<img width="963" alt="HTML Report > Test Reports view" src="https://user-images.githubusercontent.com/13063165/189140120-71a6bc41-f921-40be-a7a4-61d44da33b20.png" />
-You can click on each test and explore the tests errors as well as each step of the test.
+You can click on each test and explore the tests errors as well as each step of the test.
<img width="955" alt="HTML Reporter > Test Reports detailed view" src="https://user-images.githubusercontent.com/13063165/189140263-0e3ac2d9-4e75-40c8-b29c-58323c8be433.png" />
diff --git a/docs/src/running-tests-python.md b/docs/src/running-tests-python.md
index e250baa94f..f780805434 100644
--- a/docs/src/running-tests-python.md
+++ b/docs/src/running-tests-python.md
@@ -59,7 +59,7 @@ For more information see [Playwright Pytest usage](./test-runners.md) or the Pyt
## Running Tests
-Since Playwright runs in Python, you can debug it with your debugger of choice with e.g. the [Python extension](https://code.visualstudio.com/docs/python/python-tutorial) in Visual Studio Code. Playwright comes with the Playwright Inspector which allows you to step through Playwright API calls, see their debug logs and explore [selectors](./selectors.md).
+Since Playwright runs in Python, you can debug it with your debugger of choice with e.g. the [Python extension](https://code.visualstudio.com/docs/python/python-tutorial) in Visual Studio Code. Playwright comes with the Playwright Inspector which allows you to step through Playwright API calls, see their debug logs and explore [locators](./locators.md).
```bash tab=bash-bash lang=python
diff --git a/docs/src/testing-library-js.md b/docs/src/testing-library-js.md
index 814e565167..93e30a54f2 100644
--- a/docs/src/testing-library-js.md
+++ b/docs/src/testing-library-js.md
@@ -145,7 +145,6 @@ Learn more about Playwright Test runner:
- [Getting Started](./intro)
- [Experimental Component Testing](./test-components)
-- [Locators](./api/class-locator)
-- [Selectors](./selectors)
+- [Locators](./locators.md)
- [Assertions](./test-assertions)
- [Auto-waiting](./actionability)
diff --git a/docs/src/why-playwright.md b/docs/src/why-playwright.md
index 755f20000f..530f9c9995 100644
--- a/docs/src/why-playwright.md
+++ b/docs/src/why-playwright.md
@@ -24,13 +24,13 @@ Playwright enables fast, reliable and capable testing and automation across all
* **Fast isolation with browser contexts**. Reuse a single browser instance for multiple isolated execution environments with [browser contexts](./browser-contexts.md).
-* **Resilient element selectors**. Playwright can rely on user-facing strings, like text content and accessibility labels to [select elements](./selectors.md). These strings are more resilient than selectors tightly-coupled to the DOM structure.
+* **Resilient element locators**. Playwright can rely on user-facing strings, like text content and accessibility attributes to [locate elements](./locators.md). These locators are more resilient than selectors tightly-coupled to the DOM structure.
## Powerful automation capabilities
* **Multiple domains, pages and frames**. Playwright is an out-of-process automation driver that is not limited by the scope of in-page JavaScript execution and can automate scenarios with [multiple pages](./pages.md).
* **Powerful network control**. Playwright introduces context-wide [network interception](./network.md) to stub and mock network requests.
-* **Modern web features**. Playwright supports web components through [shadow-piercing selectors](./selectors.md), [geolocation, permissions](./emulation.md), web workers and other modern web APIs.
+* **Modern web features**. Playwright supports web components through [shadow-piercing locators](./locators.md), [geolocation, permissions](./emulation.md), web workers and other modern web APIs.
* **Capabilities to cover all scenarios**. Support for [file downloads](./downloads.md) and [uploads](./input.md), out-of-process iframes, native [input events](./input.md), and even [dark mode](./emulation.md).
diff --git a/docs/src/writing-tests-java.md b/docs/src/writing-tests-java.md
index b580bd9b75..17b13d3f53 100644
--- a/docs/src/writing-tests-java.md
+++ b/docs/src/writing-tests-java.md
@@ -67,7 +67,7 @@ assertThat(getStarted).hasAttribute("href", "/docs/intro");
getStarted.click();
```
-[Selectors](./selectors.md) are strings that are used to create Locators. Playwright supports many different selectors like [Text](./selectors.md#text-selector), [CSS](./selectors.md#css-selector), [XPath](./selectors.md#xpath-selectors) and many more. Learn more about available selectors and how to pick one in this [in-depth guide](./selectors.md).
+Playwright supports many different locators like [role](./locators.md#locate-by-role) [text](./locators.md#get-by-text), [test id](./locators.md#get-by-test-id) and many more. Learn more about available locators and how to pick one in this [in-depth guide](./locators.md).
```java
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index 1eeb1351db..50245746cc 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -291,7 +291,7 @@ export interface Page {
* The method finds an element matching the specified selector within the page. If no elements match the selector, the
* return value resolves to `null`. To wait for an element on the page, use
* [locator.waitFor([options])](https://playwright.dev/docs/api/class-locator#locator-wait-for).
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
$<K extends keyof HTMLElementTagNameMap>(selector: K, options?: { strict: boolean }): Promise<ElementHandleForTag<K> | null>;
@@ -301,7 +301,7 @@ export interface Page {
* The method finds an element matching the specified selector within the page. If no elements match the selector, the
* return value resolves to `null`. To wait for an element on the page, use
* [locator.waitFor([options])](https://playwright.dev/docs/api/class-locator#locator-wait-for).
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
$(selector: string, options?: { strict: boolean }): Promise<ElementHandle<SVGElement | HTMLElement> | null>;
@@ -311,7 +311,7 @@ export interface Page {
*
* The method finds all elements matching the specified selector within the page. If no elements match the selector,
* the return value resolves to `[]`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
*/
$$<K extends keyof HTMLElementTagNameMap>(selector: K): Promise<ElementHandleForTag<K>[]>;
/**
@@ -319,7 +319,7 @@ export interface Page {
*
* The method finds all elements matching the specified selector within the page. If no elements match the selector,
* the return value resolves to `[]`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
*/
$$(selector: string): Promise<ElementHandle<SVGElement | HTMLElement>[]>;
@@ -344,7 +344,7 @@ export interface Page {
* const preloadHrefTS = await page.$eval('link[rel=preload]', (el: HTMLLinkElement) => el.href);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -371,7 +371,7 @@ export interface Page {
* const preloadHrefTS = await page.$eval('link[rel=preload]', (el: HTMLLinkElement) => el.href);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -398,7 +398,7 @@ export interface Page {
* const preloadHrefTS = await page.$eval('link[rel=preload]', (el: HTMLLinkElement) => el.href);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -425,7 +425,7 @@ export interface Page {
* const preloadHrefTS = await page.$eval('link[rel=preload]', (el: HTMLLinkElement) => el.href);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -449,7 +449,7 @@ export interface Page {
* const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -471,7 +471,7 @@ export interface Page {
* const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -493,7 +493,7 @@ export interface Page {
* const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -515,7 +515,7 @@ export interface Page {
* const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -624,7 +624,7 @@ export interface Page {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options?: PageWaitForSelectorOptionsNotHidden): Promise<ElementHandleForTag<K>>;
@@ -658,7 +658,7 @@ export interface Page {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options?: PageWaitForSelectorOptionsNotHidden): Promise<ElementHandle<SVGElement | HTMLElement>>;
@@ -692,7 +692,7 @@ export interface Page {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options: PageWaitForSelectorOptions): Promise<ElementHandleForTag<K> | null>;
@@ -726,7 +726,7 @@ export interface Page {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options: PageWaitForSelectorOptions): Promise<null|ElementHandle<SVGElement | HTMLElement>>;
@@ -1814,7 +1814,7 @@ export interface Page {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
check(selector: string, options?: {
@@ -1876,7 +1876,7 @@ export interface Page {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
click(selector: string, options?: {
@@ -1997,7 +1997,7 @@ export interface Page {
*
* **NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
dblclick(selector: string, options?: {
@@ -2094,7 +2094,7 @@ export interface Page {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param type DOM event type: `"click"`, `"dragstart"`, etc.
* @param eventInit Optional event-specific initialization properties.
* @param options
@@ -2131,9 +2131,9 @@ export interface Page {
* ```
*
* @param source A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will
- * be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * be used.
* @param target A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first
- * will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * will be used.
* @param options
*/
dragAndDrop(source: string, target: string, options?: {
@@ -2312,7 +2312,7 @@ export interface Page {
* To send fine-grained keyboard events, use
* [page.type(selector, text[, options])](https://playwright.dev/docs/api/class-page#page-type).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options
*/
@@ -2350,7 +2350,7 @@ export interface Page {
* This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the
* method waits until a matching element appears in the DOM.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
focus(selector: string, options?: {
@@ -2410,7 +2410,7 @@ export interface Page {
* await locator.click();
* ```
*
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
*/
frameLocator(selector: string): FrameLocator;
@@ -2424,7 +2424,7 @@ export interface Page {
*
* Returns element attribute value.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param name Attribute name to get the value for.
* @param options
*/
@@ -2793,7 +2793,7 @@ export interface Page {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
hover(selector: string, options?: {
@@ -2851,7 +2851,7 @@ export interface Page {
*
* Returns `element.innerHTML`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
innerHTML(selector: string, options?: {
@@ -2875,7 +2875,7 @@ export interface Page {
*
* Returns `element.innerText`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
innerText(selector: string, options?: {
@@ -2903,7 +2903,7 @@ export interface Page {
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the
* control.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
inputValue(selector: string, options?: {
@@ -2927,7 +2927,7 @@ export interface Page {
*
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isChecked(selector: string, options?: {
@@ -2956,7 +2956,7 @@ export interface Page {
*
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isDisabled(selector: string, options?: {
@@ -2980,7 +2980,7 @@ export interface Page {
*
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isEditable(selector: string, options?: {
@@ -3004,7 +3004,7 @@ export interface Page {
*
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isEnabled(selector: string, options?: {
@@ -3029,7 +3029,7 @@ export interface Page {
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that
* does not match any elements is considered hidden.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isHidden(selector: string, options?: {
@@ -3052,7 +3052,7 @@ export interface Page {
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements
* is considered not visible.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isVisible(selector: string, options?: {
@@ -3077,7 +3077,7 @@ export interface Page {
* performed on different DOM elements. That would happen if the DOM structure between those actions has changed.
*
* [Learn more about locators](https://playwright.dev/docs/locators).
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
* @param options
*/
locator(selector: string, options?: {
@@ -3309,7 +3309,7 @@ export interface Page {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
* @param options
*/
@@ -3515,7 +3515,7 @@ export interface Page {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param values Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise
* only the first option matching one of the passed options is selected. String values are equivalent to
* `{value:'string'}`. Option is considered matching if all specified properties match.
@@ -3597,7 +3597,7 @@ export interface Page {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param checked Whether to check or uncheck the checkbox.
* @param options
*/
@@ -3725,7 +3725,7 @@ export interface Page {
* the `<label>` element that has an associated
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param files
* @param options
*/
@@ -3838,7 +3838,7 @@ export interface Page {
* **NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) requires that the
* `hasTouch` option of the browser context be set to true.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
tap(selector: string, options?: {
@@ -3896,7 +3896,7 @@ export interface Page {
*
* Returns `element.textContent`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
textContent(selector: string, options?: {
@@ -3940,7 +3940,7 @@ export interface Page {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param text A text to type into a focused element.
* @param options
*/
@@ -3990,7 +3990,7 @@ export interface Page {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
uncheck(selector: string, options?: {
@@ -4698,9 +4698,9 @@ export interface Frame {
*
* **NOTE** The use of [ElementHandle] is discouraged, use [Locator] objects and web-first assertions instead.
*
- * The method finds an element matching the specified selector within the frame. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns `null`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds an element matching the specified selector within the frame. If no elements match the selector,
+ * returns `null`.
+ * @param selector A selector to query for.
* @param options
*/
$<K extends keyof HTMLElementTagNameMap>(selector: K, options?: { strict: boolean }): Promise<ElementHandleForTag<K> | null>;
@@ -4711,9 +4711,9 @@ export interface Frame {
*
* **NOTE** The use of [ElementHandle] is discouraged, use [Locator] objects and web-first assertions instead.
*
- * The method finds an element matching the specified selector within the frame. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns `null`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds an element matching the specified selector within the frame. If no elements match the selector,
+ * returns `null`.
+ * @param selector A selector to query for.
* @param options
*/
$(selector: string, options?: { strict: boolean }): Promise<ElementHandle<SVGElement | HTMLElement> | null>;
@@ -4725,9 +4725,9 @@ export interface Frame {
*
* **NOTE** The use of [ElementHandle] is discouraged, use [Locator] objects instead.
*
- * The method finds all elements matching the specified selector within the frame. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns empty array.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds all elements matching the specified selector within the frame. If no elements match the selector,
+ * returns empty array.
+ * @param selector A selector to query for.
*/
$$<K extends keyof HTMLElementTagNameMap>(selector: K): Promise<ElementHandleForTag<K>[]>;
/**
@@ -4737,9 +4737,9 @@ export interface Frame {
*
* **NOTE** The use of [ElementHandle] is discouraged, use [Locator] objects instead.
*
- * The method finds all elements matching the specified selector within the frame. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns empty array.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds all elements matching the specified selector within the frame. If no elements match the selector,
+ * returns empty array.
+ * @param selector A selector to query for.
*/
$$(selector: string): Promise<ElementHandle<SVGElement | HTMLElement>[]>;
@@ -4750,8 +4750,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector within the frame and passes it as a first argument to
- * `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector,
- * the method throws an error.
+ * `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [frame.$eval(selector, pageFunction[, arg, options])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector)
@@ -4765,7 +4764,7 @@ export interface Frame {
* const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -4778,8 +4777,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector within the frame and passes it as a first argument to
- * `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector,
- * the method throws an error.
+ * `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [frame.$eval(selector, pageFunction[, arg, options])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector)
@@ -4793,7 +4791,7 @@ export interface Frame {
* const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -4806,8 +4804,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector within the frame and passes it as a first argument to
- * `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector,
- * the method throws an error.
+ * `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [frame.$eval(selector, pageFunction[, arg, options])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector)
@@ -4821,7 +4818,7 @@ export interface Frame {
* const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -4834,8 +4831,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector within the frame and passes it as a first argument to
- * `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector,
- * the method throws an error.
+ * `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [frame.$eval(selector, pageFunction[, arg, options])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector)
@@ -4849,7 +4845,7 @@ export interface Frame {
* const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
* @param options
@@ -4863,7 +4859,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector within the frame and passes an array of matched
- * elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [frame.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector-all)
@@ -4875,7 +4871,7 @@ export interface Frame {
* const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -4887,7 +4883,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector within the frame and passes an array of matched
- * elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [frame.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector-all)
@@ -4899,7 +4895,7 @@ export interface Frame {
* const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -4911,7 +4907,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector within the frame and passes an array of matched
- * elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [frame.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector-all)
@@ -4923,7 +4919,7 @@ export interface Frame {
* const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -4935,7 +4931,7 @@ export interface Frame {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector within the frame and passes an array of matched
- * elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [frame.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-frame#frame-eval-on-selector-all)
@@ -4947,7 +4943,7 @@ export interface Frame {
* const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -5052,7 +5048,7 @@ export interface Frame {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options?: PageWaitForSelectorOptionsNotHidden): Promise<ElementHandleForTag<K>>;
@@ -5086,7 +5082,7 @@ export interface Frame {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options?: PageWaitForSelectorOptionsNotHidden): Promise<ElementHandle<SVGElement | HTMLElement>>;
@@ -5120,7 +5116,7 @@ export interface Frame {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options: PageWaitForSelectorOptions): Promise<ElementHandleForTag<K> | null>;
@@ -5154,7 +5150,7 @@ export interface Frame {
* })();
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options: PageWaitForSelectorOptions): Promise<null|ElementHandle<SVGElement | HTMLElement>>;
@@ -5231,7 +5227,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
check(selector: string, options?: {
@@ -5295,7 +5291,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
click(selector: string, options?: {
@@ -5386,7 +5382,7 @@ export interface Frame {
*
* **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
dblclick(selector: string, options?: {
@@ -5483,7 +5479,7 @@ export interface Frame {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param type DOM event type: `"click"`, `"dragstart"`, etc.
* @param eventInit Optional event-specific initialization properties.
* @param options
@@ -5506,9 +5502,9 @@ export interface Frame {
/**
* @param source A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will
- * be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * be used.
* @param target A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first
- * will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * will be used.
* @param options
*/
dragAndDrop(source: string, target: string, options?: {
@@ -5580,7 +5576,7 @@ export interface Frame {
* To send fine-grained keyboard events, use
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options
*/
@@ -5618,7 +5614,7 @@ export interface Frame {
* This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the
* method waits until a matching element appears in the DOM.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
focus(selector: string, options?: {
@@ -5671,7 +5667,7 @@ export interface Frame {
* await locator.click();
* ```
*
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
*/
frameLocator(selector: string): FrameLocator;
@@ -5680,7 +5676,7 @@ export interface Frame {
*
* Returns element attribute value.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param name Attribute name to get the value for.
* @param options
*/
@@ -5987,7 +5983,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
hover(selector: string, options?: {
@@ -6045,7 +6041,7 @@ export interface Frame {
*
* Returns `element.innerHTML`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
innerHTML(selector: string, options?: {
@@ -6069,7 +6065,7 @@ export interface Frame {
*
* Returns `element.innerText`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
innerText(selector: string, options?: {
@@ -6097,7 +6093,7 @@ export interface Frame {
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the
* control.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
inputValue(selector: string, options?: {
@@ -6121,7 +6117,7 @@ export interface Frame {
*
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isChecked(selector: string, options?: {
@@ -6150,7 +6146,7 @@ export interface Frame {
*
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isDisabled(selector: string, options?: {
@@ -6174,7 +6170,7 @@ export interface Frame {
*
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isEditable(selector: string, options?: {
@@ -6196,7 +6192,7 @@ export interface Frame {
/**
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isEnabled(selector: string, options?: {
@@ -6221,7 +6217,7 @@ export interface Frame {
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that
* does not match any elements is considered hidden.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isHidden(selector: string, options?: {
@@ -6244,7 +6240,7 @@ export interface Frame {
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements
* is considered not visible.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
isVisible(selector: string, options?: {
@@ -6269,7 +6265,7 @@ export interface Frame {
* [Learn more about locators](https://playwright.dev/docs/locators).
*
* [Learn more about locators](https://playwright.dev/docs/locators).
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
* @param options
*/
locator(selector: string, options?: {
@@ -6331,7 +6327,7 @@ export interface Frame {
* Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
* modifier, modifier is pressed and being held while the subsequent key is being pressed.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
* @param options
*/
@@ -6391,7 +6387,7 @@ export interface Frame {
* frame.selectOption('select#colors', 'red', 'green', 'blue');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param values Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise
* only the first option matching one of the passed options is selected. String values are equivalent to
* `{value:'string'}`. Option is considered matching if all specified properties match.
@@ -6473,7 +6469,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param checked Whether to check or uncheck the checkbox.
* @param options
*/
@@ -6559,7 +6555,7 @@ export interface Frame {
* the `<label>` element that has an associated
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param files
* @param options
*/
@@ -6633,7 +6629,7 @@ export interface Frame {
*
* **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
tap(selector: string, options?: {
@@ -6691,7 +6687,7 @@ export interface Frame {
*
* Returns `element.textContent`.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
textContent(selector: string, options?: {
@@ -6733,7 +6729,7 @@ export interface Frame {
* ```
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param text A text to type into a focused element.
* @param options
*/
@@ -6783,7 +6779,7 @@ export interface Frame {
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
* Passing zero timeout disables this.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
- * used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * used.
* @param options
*/
uncheck(selector: string, options?: {
@@ -8364,28 +8360,28 @@ export interface JSHandle<T = any> {
*/
export interface ElementHandle<T=Node> extends JSHandle<T> {
/**
- * The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns `null`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds an element matching the specified selector in the `ElementHandle`'s subtree. If no elements match
+ * the selector, returns `null`.
+ * @param selector A selector to query for.
*/
$<K extends keyof HTMLElementTagNameMap>(selector: K, options?: { strict: boolean }): Promise<ElementHandleForTag<K> | null>;
/**
- * The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns `null`.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds an element matching the specified selector in the `ElementHandle`'s subtree. If no elements match
+ * the selector, returns `null`.
+ * @param selector A selector to query for.
*/
$(selector: string, options?: { strict: boolean }): Promise<ElementHandle<SVGElement | HTMLElement> | null>;
/**
- * The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns empty array.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds all elements matching the specified selector in the `ElementHandle`s subtree. If no elements match
+ * the selector, returns empty array.
+ * @param selector A selector to query for.
*/
$$<K extends keyof HTMLElementTagNameMap>(selector: K): Promise<ElementHandleForTag<K>[]>;
/**
- * The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See
- * [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements match the selector, returns empty array.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * The method finds all elements matching the specified selector in the `ElementHandle`s subtree. If no elements match
+ * the selector, returns empty array.
+ * @param selector A selector to query for.
*/
$$(selector: string): Promise<ElementHandle<SVGElement | HTMLElement>[]>;
@@ -8393,8 +8389,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a
- * first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements
- * match the selector, the method throws an error.
+ * first argument to `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector)
@@ -8408,7 +8403,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8417,8 +8412,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a
- * first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements
- * match the selector, the method throws an error.
+ * first argument to `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector)
@@ -8432,7 +8426,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8441,8 +8435,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a
- * first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements
- * match the selector, the method throws an error.
+ * first argument to `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector)
@@ -8456,7 +8449,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8465,8 +8458,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a
- * first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more details. If no elements
- * match the selector, the method throws an error.
+ * first argument to `pageFunction`. If no elements match the selector, the method throws an error.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector)
@@ -8480,7 +8472,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8490,8 +8482,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array
- * of matched elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more
- * details.
+ * of matched elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector-all)
@@ -8511,7 +8502,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8520,8 +8511,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array
- * of matched elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more
- * details.
+ * of matched elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector-all)
@@ -8541,7 +8531,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8550,8 +8540,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array
- * of matched elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more
- * details.
+ * of matched elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector-all)
@@ -8571,7 +8560,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8580,8 +8569,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* Returns the return value of `pageFunction`.
*
* The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array
- * of matched elements as a first argument to `pageFunction`. See [Working with selectors](https://playwright.dev/docs/selectors) for more
- * details.
+ * of matched elements as a first argument to `pageFunction`.
*
* If `pageFunction` returns a [Promise], then
* [elementHandle.$$eval(selector, pageFunction[, arg])](https://playwright.dev/docs/api/class-elementhandle#element-handle-eval-on-selector-all)
@@ -8601,7 +8589,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
* ```
*
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param pageFunction Function to be evaluated in the page context.
* @param arg Optional argument to pass to `pageFunction`.
*/
@@ -8628,7 +8616,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* **NOTE** This method does not work across navigations, use
* [page.waitForSelector(selector[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-selector)
* instead.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options?: ElementHandleWaitForSelectorOptionsNotHidden): Promise<ElementHandleForTag<K>>;
@@ -8653,7 +8641,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* **NOTE** This method does not work across navigations, use
* [page.waitForSelector(selector[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-selector)
* instead.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options?: ElementHandleWaitForSelectorOptionsNotHidden): Promise<ElementHandle<SVGElement | HTMLElement>>;
@@ -8678,7 +8666,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* **NOTE** This method does not work across navigations, use
* [page.waitForSelector(selector[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-selector)
* instead.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector<K extends keyof HTMLElementTagNameMap>(selector: K, options: ElementHandleWaitForSelectorOptions): Promise<ElementHandleForTag<K> | null>;
@@ -8703,7 +8691,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* **NOTE** This method does not work across navigations, use
* [page.waitForSelector(selector[, options])](https://playwright.dev/docs/api/class-page#page-wait-for-selector)
* instead.
- * @param selector A selector to query for. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to query for.
* @param options
*/
waitForSelector(selector: string, options: ElementHandleWaitForSelectorOptions): Promise<null|ElementHandle<SVGElement | HTMLElement>>;
@@ -10386,7 +10374,7 @@ export interface Locator {
* await locator.click();
* ```
*
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
*/
frameLocator(selector: string): FrameLocator;
@@ -10826,7 +10814,7 @@ export interface Locator {
* method.
*
* [Learn more about locators](https://playwright.dev/docs/locators).
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
* @param options
*/
locator(selector: string, options?: {
@@ -15922,7 +15910,7 @@ export interface FrameLocator {
/**
* When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
* in that iframe.
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
*/
frameLocator(selector: string): FrameLocator;
@@ -16157,7 +16145,7 @@ export interface FrameLocator {
* method.
*
* [Learn more about locators](https://playwright.dev/docs/locators).
- * @param selector A selector to use when resolving DOM element. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
+ * @param selector A selector to use when resolving DOM element.
* @param options
*/
locator(selector: string, options?: {
@@ -16534,7 +16522,7 @@ export const firefox: BrowserType;
export const request: APIRequest;
/**
- * Selectors can be used to install custom selector engines. See [Working with selectors](https://playwright.dev/docs/selectors) for more
+ * Selectors can be used to install custom selector engines. See [extensibility](https://playwright.dev/docs/extensibility) for more
* information.
*/
export const selectors: Selectors;
@@ -17252,7 +17240,7 @@ export interface Route {
}
/**
- * Selectors can be used to install custom selector engines. See [Working with selectors](https://playwright.dev/docs/selectors) for more
+ * Selectors can be used to install custom selector engines. See [extensibility](https://playwright.dev/docs/extensibility) for more
* information.
*/
export interface Selectors {