Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: unexperiment role selectors (#13858)
Andrey Lushnikovbd2a2873b779
diff --git a/docs/src/release-notes-csharp.md b/docs/src/release-notes-csharp.mdindex 369e4e5b01..40bfd07506 100644--- a/docs/src/release-notes-csharp.md+++ b/docs/src/release-notes-csharp.md@@ -9,15 +9,13 @@ title: "Release notes"### Highlights-- New **experimental** role selectors that allow 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).+- New role selectors that allow 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).```csharp// Click a button with accessible name "log in"await page.ClickAsync("role=button[name='log in']")```- To use role selectors, make sure to pass `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` environment variable.-Read more in [our documentation](./selectors#role-selector).- 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"`.diff --git a/docs/src/release-notes-java.md b/docs/src/release-notes-java.mdindex 071f115b34..a77252035c 100644--- a/docs/src/release-notes-java.md+++ b/docs/src/release-notes-java.md@@ -9,15 +9,13 @@ title: "Release notes"### Highlights-- New **experimental** role selectors that allow 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).+- New role selectors that allow 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).```java// Click a button with accessible name "log in"page.click("role=button[name='log in']")```- To use role selectors, make sure to pass `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` environment variable.-Read more in [our documentation](./selectors#role-selector).- 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"`.diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.mdindex 4d937120e6..cd9ca57885 100644--- a/docs/src/release-notes-js.md+++ b/docs/src/release-notes-js.md@@ -9,23 +9,13 @@ title: "Release notes"### Highlights-- New **experimental** role selectors that allow 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).+- New role selectors that allow 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).```js// Click a button with accessible name "log in"await page.click('role=button[name="log in"]')```- To use role selectors, make sure to pass `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` environment variable:-- ```js- // playwright.config.js- process.env.PLAYWRIGHT_EXPERIMENTAL_FEATURES = '1';- module.exports = {- /* ... */- };- ```-Read more in [our documentation](./selectors#role-selector).- 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"`.diff --git a/docs/src/release-notes-python.md b/docs/src/release-notes-python.mdindex 6792fa1f88..650368ffc1 100644--- a/docs/src/release-notes-python.md+++ b/docs/src/release-notes-python.md@@ -9,7 +9,7 @@ title: "Release notes"### Highlights-- New **experimental** role selectors that allow 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).+- New role selectors that allow 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).```python async# Click a button with accessible name "log in"@@ -21,8 +21,6 @@ title: "Release notes"page.click("role=button[name='log in']")```- To use role selectors, make sure to pass `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` environment variable.-Read more in [our documentation](./selectors#role-selector).- 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"`.diff --git a/docs/src/selectors.md b/docs/src/selectors.mdindex 1fde529929..4719819d27 100644--- a/docs/src/selectors.md+++ b/docs/src/selectors.md@@ -948,10 +948,6 @@ Vue selectors, as well as [Vue DevTools](https://chrome.google.com/webstore/deta## Role selector-:::note-Role selector is experimental, only available when running with `PLAYWRIGHT_EXPERIMENTAL_FEATURES=1` enviroment variable.-:::-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".diff --git a/packages/playwright-core/src/server/injected/injectedScript.ts b/packages/playwright-core/src/server/injected/injectedScript.tsindex cbc6bdb313..61d3833d89 100644--- a/packages/playwright-core/src/server/injected/injectedScript.ts+++ b/packages/playwright-core/src/server/injected/injectedScript.ts@@ -86,8 +86,7 @@ export class InjectedScript {this._engines.set('xpath:light', XPathEngine);this._engines.set('_react', ReactEngine);this._engines.set('_vue', VueEngine);- if (experimentalFeaturesEnabled)- this._engines.set('role', RoleEngine);+ this._engines.set('role', RoleEngine);this._engines.set('text', this._createTextEngine(true));this._engines.set('text:light', this._createTextEngine(false));this._engines.set('id', this._createAttributeEngine('id', true));diff --git a/packages/playwright-core/src/server/selectors.ts b/packages/playwright-core/src/server/selectors.tsindex e1117dd3a2..5ac6ab379a 100644--- a/packages/playwright-core/src/server/selectors.ts+++ b/packages/playwright-core/src/server/selectors.ts@@ -20,7 +20,7 @@ import type * as js from './javascript';import type * as types from './types';import type { ParsedSelector } from './isomorphic/selectorParser';import { allEngineNames, InvalidSelectorError, parseSelector, stringifySelector } from './isomorphic/selectorParser';-import { createGuid, experimentalFeaturesEnabled } from '../utils';+import { createGuid } from '../utils';export type SelectorInfo = {parsed: ParsedSelector,@@ -134,8 +134,7 @@ export class Selectors {}parseSelector(selector: string | ParsedSelector, strict: boolean): SelectorInfo {- if (experimentalFeaturesEnabled())- this._builtinEngines.add('role');+ this._builtinEngines.add('role');const parsed = typeof selector === 'string' ? parseSelector(selector) : selector;let needsMainWorld = false;for (const name of allEngineNames(parsed)) {