You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`engineFunction` <[function]|[string]> Function that evaluates to a selector engine instance.
3157
-
-`...args` <...[Serializable]> Arguments to pass to `engineFunction`.
3155
+
#### selectors.register(name, script)
3156
+
-`name` <[string]> 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.
3157
+
-`script` <[function]|[string]|[Object]> Script that evaluates to a selector engine instance.
3158
+
-`path` <[string]> Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd).
3159
+
-`content` <[string]> Raw script content.
3158
3160
- returns: <[Promise]>
3159
3161
3160
3162
An example of registering selector engine that queries elements based on a tag name:
@@ -3164,9 +3166,6 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk
3164
3166
(async () => {
3165
3167
// Must be a function that evaluates to a selector engine instance.
3166
3168
constcreateTagNameEngine= () => ({
3167
-
// Selectors will be prefixed with "tag=".
3168
-
name:'tag',
3169
-
3170
3169
// Creates a selector that matches given target when queried at the root.
3171
3170
// Can return undefined if unable to create one.
3172
3171
create(root, target) {
@@ -3184,8 +3183,8 @@ const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webk
3184
3183
}
3185
3184
});
3186
3185
3187
-
// Register the engine.
3188
-
awaitselectors.register(createTagNameEngine);
3186
+
// Register the engine. Selectors will be prefixed with "tag=".
0 commit comments