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
docs: explain that the `Selectors.register` script is executed in the page context (#16917)
DetachHeadbcf2a06e5322
diff --git a/docs/src/api/class-selectors.md b/docs/src/api/class-selectors.mdindex 51241b070d..397d3975a5 100644--- a/docs/src/api/class-selectors.md+++ b/docs/src/api/class-selectors.md@@ -45,7 +45,7 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk``````java-// Script that evaluates to a selector engine instance.+// Script that evaluates to a selector engine instance. The script is evaluated in the page context.String createTagNameEngine = "{\n" +" // Returns the first element matching given selector in the root's subtree.\n" +" query(root, selector) {\n" +@@ -146,7 +146,7 @@ with sync_playwright() as playwright:```csharpusing var playwright = await Playwright.CreateAsync();-// Script that evaluates to a selector engine instance.+// Script that evaluates to a selector engine instance. The script is evaluated in the page context.await playwright.Selectors.RegisterAsync("tag", @"{// Returns the first element matching given selector in the root's subtree.query(root, selector) {@@ -184,28 +184,28 @@ contain `[a-zA-Z0-9_]` characters.current working directory. Optional.- `content` ?<[string]> Raw script content. Optional.-Script that evaluates to a selector engine instance.+Script that evaluates to a selector engine instance. The script is evaluated in the page context.### param: Selectors.register.script* since: v1.8* langs: java- `script` <[string]|[path]>-Script that evaluates to a selector engine instance.+Script that evaluates to a selector engine instance. The script is evaluated in the page context.### option: Selectors.register.script* since: v1.8* langs: csharp- `script` <[string]>-Script that evaluates to a selector engine instance.+Script that evaluates to a selector engine instance. The script is evaluated in the page context.### option: Selectors.register.path* since: v1.8* langs: csharp- `path` <[path]>-Script that evaluates to a selector engine instance.+Script that evaluates to a selector engine instance. The script is evaluated in the page context.### option: Selectors.register.contentScript* since: v1.8@@ -213,4 +213,4 @@ Script that evaluates to a selector engine instance.Whether to run this selector engine in isolated JavaScript environment. This environment has access to the same DOM, butnot any JavaScript objects from the frame's scripts. Defaults to `false`. Note that running as a content script is not-guaranteed when this engine is used together with other registered engines.\ No newline at end of file+guaranteed when this engine is used together with other registered engines.diff --git a/docs/src/extensibility.md b/docs/src/extensibility.mdindex 2910c3f4d4..e8f21c64fb 100644--- a/docs/src/extensibility.md+++ b/docs/src/extensibility.md@@ -53,7 +53,7 @@ const buttonCount = await page.locator('tag=button').count();``````java-// Must be a script that evaluates to a selector engine instance.+// Must be a script that evaluates to a selector engine instance. The script is evaluated in the page context.String createTagNameEngine = "{\n" +" // Returns the first element matching given selector in the root's subtree.\n" +" query(root, selector) {\n" +diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex b379938cc8..e95a706490 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -15532,7 +15532,7 @@ export interface Selectors {* ```** @param name Name that is used in selectors as a prefix, e.g. `{name: 'foo'}` enables `foo=myselectorbody` selectors. May only contain `[a-zA-Z0-9_]` characters.- * @param script Script that evaluates to a selector engine instance.+ * @param script Script that evaluates to a selector engine instance. The script is evaluated in the page context.* @param options*/register(name: string, script: Function|string|{