Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/pptr/mod.ts>Frame

Headless Chrome Deno API
Latest
class Frame
Re-export
import { Frame } from "https://deno.land/x/pptr@1.2.0/mod.ts";

At every point of time, page exposes its current frame tree via the Page.mainFrame | page.mainFrame and Frame.childFrames | frame.childFrames methods.

Constructors

new
Frame(
frameManager: FrameManager,
parentFrame: Frame | null,
frameId: string,
)

Properties

private
_detached: boolean
private
_parentFrame: Frame | null
private
_url: string
_childFrames: Set<Frame>
_frameManager: FrameManager
_id: string
_lifecycleEvents: Set<string>
_loaderId: string
_mainWorld: DOMWorld
optional
_name: string
_secondaryWorld: DOMWorld

Methods

_detach(): void
_navigated(framePayload: Protocol.Page.Frame): void
_navigatedWithinDocument(url: string): void
_onLifecycleEvent(loaderId: string, name: string): void
$(selector: string): Promise<ElementHandle | null>

This method queries the frame for the given selector.

$$(selector: string): Promise<ElementHandle[]>

This runs document.querySelectorAll in the frame and returns the result.

$$eval<ReturnType>(
selector: string,
pageFunction: (elements: Element[], ...args: unknown[]) => ReturnType | Promise<ReturnType>,
): Promise<WrapElementHandle<ReturnType>>
$eval<ReturnType>(
selector: string,
pageFunction: (element: Element, ...args: unknown[]) => ReturnType | Promise<ReturnType>,
): Promise<WrapElementHandle<ReturnType>>
$x(expression: string): Promise<ElementHandle[]>

This method evaluates the given XPath expression and returns the results.

Adds a <script> tag into the page with the desired url or content.

Adds a <link rel="stylesheet"> tag into the page with the desired url or a <style type="text/css"> tag with the content.

click(selector: string, options?: { delay?: number; button?: MouseButton; clickCount?: number; }): Promise<void>

This method clicks the first element found that matches selector.

content(): Promise<string>
evaluate<T extends EvaluateFn>(pageFunction: T, ...args: SerializableOrJSHandle[]): Promise<UnwrapPromiseLike<EvaluateFnReturnType<T>>>
evaluateHandle<HandlerType extends JSHandle = JSHandle>(pageFunction: EvaluateHandleFn, ...args: SerializableOrJSHandle[]): Promise<HandlerType>
focus(selector: string): Promise<void>

This method fetches an element with selector and focuses it.

goto(url: string, options?: { referer?: string; timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>
hover(selector: string): Promise<void>

This method fetches an element with selector, scrolls it into view if needed, and then uses Page.mouse to hover over the center of the element.

isDetached(): boolean
name(): string
parentFrame(): Frame | null
select(selector: string, ...values: string[]): Promise<string[]>

Triggers a change and input event once all the provided options have been selected.

setContent(html: string, options?: { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<void>

Set the content of the frame.

tap(selector: string): Promise<void>

This method fetches an element with selector, scrolls it into view if needed, and then uses Page.touchscreen to tap in the center of the element.

title(): Promise<string>
type(
selector: string,
text: string,
options?: { delay: number; },
): Promise<void>

Sends a keydown, keypress/input, and keyup event for each character in the text.

url(): string
waitForFunction(
pageFunction: Function | string,
): Promise<JSHandle>
waitForNavigation(options?: { timeout?: number; waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]; }): Promise<HTTPResponse | null>
waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<ElementHandle | null>
waitForTimeout(milliseconds: number): Promise<void>

Causes your script to wait for the given number of milliseconds.

waitForXPath(xpath: string, options?: WaitForSelectorOptions): Promise<ElementHandle | null>