puppeteer/docs/api/puppeteer.page._.md

51 lines
793 B
Markdown
Raw Normal View History

2022-07-05 13:41:43 +00:00
---
sidebar_label: Page.$
---
# Page.$() method
Runs `document.querySelector` within the page. If no element matches the selector, the return value resolves to `null`.
#### Signature:
2022-07-05 13:41:43 +00:00
```typescript
class Page {
$<Selector extends string>(
2022-07-05 13:41:43 +00:00
selector: Selector
): Promise<ElementHandle<NodeFor<Selector>> | null>;
2022-07-05 13:41:43 +00:00
}
```
## Parameters
<table><thead><tr><th>
2022-07-05 13:41:43 +00:00
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
selector
</td><td>
Selector
</td><td>
A `selector` to query page for [selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to query page for.
</td></tr>
</tbody></table>
2022-07-05 13:41:43 +00:00
**Returns:**
Promise&lt;[ElementHandle](./puppeteer.elementhandle.md)&lt;[NodeFor](./puppeteer.nodefor.md)&lt;Selector&gt;&gt; \| null&gt;