docs: rework Selectors to Other Locators (#19244)
- Replace links to `selectors.md` with `locators.md`. - Remove sections that are covered by Locators docs. - Restructure the rest of selectors doc, update them in terms of locators. Fixes #18992.
This commit is contained in:
Родитель
9b35ef3b8d
Коммит
e55a2bdf16
|
@ -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-%%
|
||||
|
|
|
@ -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-%%
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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">>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" />
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче