From bd2a2873b7793486fb11806c2c0b2d7a178d7bff Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 2 May 2022 10:32:50 -0600 Subject: [PATCH] chore: unexperiment role selectors (#13858) --- docs/src/release-notes-csharp.md | 4 +--- docs/src/release-notes-java.md | 4 +--- docs/src/release-notes-js.md | 12 +----------- docs/src/release-notes-python.md | 4 +--- docs/src/selectors.md | 4 ---- .../src/server/injected/injectedScript.ts | 3 +-- packages/playwright-core/src/server/selectors.ts | 5 ++--- 7 files changed, 7 insertions(+), 29 deletions(-) diff --git a/docs/src/release-notes-csharp.md b/docs/src/release-notes-csharp.md index 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.md index 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.md index 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.md index 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.md index 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.ts index 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.ts index 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)) {