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
// 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:
```csharp
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", @"{
// 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

View file

@ -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" +

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 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|{