docs: explain that the Selectors.register script is executed in the page context (#16917)

This commit is contained in:
DetachHead 2022-08-31 02:17:17 +10:00 committed by GitHub
parent d56b279622
commit bcf2a06e53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -45,7 +45,7 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk
``` ```
```java ```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" + String createTagNameEngine = "{\n" +
" // Returns the first element matching given selector in the root's subtree.\n" + " // Returns the first element matching given selector in the root's subtree.\n" +
" query(root, selector) {\n" + " query(root, selector) {\n" +
@ -146,7 +146,7 @@ with sync_playwright() as playwright:
```csharp ```csharp
using var playwright = await Playwright.CreateAsync(); using 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", @"{ await playwright.Selectors.RegisterAsync("tag", @"{
// Returns the first element matching given selector in the root's subtree. // Returns the first element matching given selector in the root's subtree.
query(root, selector) { query(root, selector) {
@ -184,28 +184,28 @@ contain `[a-zA-Z0-9_]` characters.
current working directory. Optional. current working directory. Optional.
- `content` ?<[string]> Raw script content. 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 ### param: Selectors.register.script
* since: v1.8 * since: v1.8
* langs: java * langs: java
- `script` <[string]|[path]> - `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 ### option: Selectors.register.script
* since: v1.8 * since: v1.8
* langs: csharp * langs: csharp
- `script` <[string]> - `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 ### option: Selectors.register.path
* since: v1.8 * since: v1.8
* langs: csharp * langs: csharp
- `path` <[path]> - `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 ### option: Selectors.register.contentScript
* since: v1.8 * since: v1.8

View file

@ -53,7 +53,7 @@ const buttonCount = await page.locator('tag=button').count();
``` ```
```java ```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" + String createTagNameEngine = "{\n" +
" // Returns the first element matching given selector in the root's subtree.\n" + " // Returns the first element matching given selector in the root's subtree.\n" +
" query(root, selector) {\n" + " query(root, selector) {\n" +

View file

@ -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 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 * @param options
*/ */
register(name: string, script: Function|string|{ register(name: string, script: Function|string|{