class Playwright::Selectors

information.
Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md) for more

def event_emitter_proxy

def event_emitter_proxy
_emitter_proxy ||= EventEmitterProxy.new(self, @impl)

def off(event, callback)

@nodoc
-- inherited from EventEmitter --
def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

def on(event, callback)

@nodoc
-- inherited from EventEmitter --
def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

def once(event, callback)

@nodoc
-- inherited from EventEmitter --
def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

def register(name, contentScript: nil, path: nil, script: nil)

```
# FIXME: add snippet
```python sync

```
# FIXME: add snippet
```python async

```
browser.close();
int buttonCount = (int) page.evalOnSelectorAll("tag=button", "buttons => buttons.length");
// Can use it in any methods supporting selectors.
page.click("tag=div >> text=\"Click me\"");
// Combine it with other selector engines.
ElementHandle button = page.querySelector("tag=button");
// Use the selector prefixed with its name.
page.setContent("
");
Page page = browser.newPage();
Browser browser = playwright.firefox().launch();
playwright.selectors().register("tag", createTagNameEngine);
// Register the engine. Selectors will be prefixed with "tag=".
"}";
" }\n" +
" return Array.from(root.querySelectorAll(selector));\n" +
" queryAll(root, selector) {\n" +
" // Returns all elements matching given selector in the root's subtree.\n" +
" },\n" +
" return root.querySelector(selector);\n" +
" query(root, selector) {\n" +
" // Returns the first element matching given selector in the root's subtree.\n" +
String createTagNameEngine = "{\n" +
// Script that evaluates to a selector engine instance.
```java

```
})();
await browser.close();

const buttonCount = await page.$$eval('tag=button', buttons => buttons.length);
// Can use it in any methods supporting selectors.
await page.click('tag=div >> text="Click me"');
// Combine it with other selector engines.
const button = await page.$('tag=button');
// Use the selector prefixed with its name.

await page.setContent(`
`);
const page = await browser.newPage();
const browser = await firefox.launch();

await selectors.register('tag', createTagNameEngine);
// Register the engine. Selectors will be prefixed with "tag=".

});
}
return Array.from(root.querySelectorAll(selector));
queryAll(root, selector) {
// Returns all elements matching given selector in the root's subtree.

},
return root.querySelector(selector);
query(root, selector) {
// Returns the first element matching given selector in the root's subtree.
const createTagNameEngine = () => ({
// Must be a function that evaluates to a selector engine instance.
(async () => {

const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
```js


An example of registering selector engine that queries elements based on a tag name:
def register(name, contentScript: nil, path: nil, script: nil)
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
end