Skip to main content

Interface: Webdriver

mugshot.Webdriver

Webdriver compatible client.

Implemented by#

Properties#

execute#

execute: <R, A>(func: (...args: A) => R, ...args: A) => Promise<R>

Execute a function in the current page context.

param An asynchronous function returning a promise. Needs to be serializable.

param Will be passed to the function. Needs to be serializable.

see https://w3c.github.io/webdriver/#execute-async-script

Type declaration:#

▸ <R, A>(func: (...args: A) => R, ...args: A): Promise<R>

Type parameters:#

NameType
R-
Aany[]

Parameters:#

NameType
func(...args: A) => R
...argsA

Returns: Promise<R>

Defined in: packages/mugshot/src/interfaces/webdriver.ts:51

Defined in: packages/mugshot/src/interfaces/webdriver.ts:51


getElementRect#

getElementRect: (selector: string) => Promise<null | ElementRect | ElementRect[]>

Get the dimensions and coordinates of an element.

see https://w3c.github.io/webdriver/#get-element-rect

If the selector matches more than 1 element then an array of ElementRect should be returned, otherwise a single ElementRect should be returned.

Should return null if the selector doesn't match any element.

Should return 0,0,0,0 for every element that is not visible.

Type declaration:#

▸ (selector: string): Promise<null | ElementRect | ElementRect[]>

Parameters:#

NameType
selectorstring

Returns: Promise<null | ElementRect | ElementRect[]>

Defined in: packages/mugshot/src/interfaces/webdriver.ts:28

Defined in: packages/mugshot/src/interfaces/webdriver.ts:28


setViewportSize#

setViewportSize: (width: number, height: number) => Promise<void>

Set the size of the viewport (meaning window minus chrome).

This is unlike setWindowRect which doesn't take the chrome into account.

see https://w3c.github.io/webdriver/#set-window-rect

Type declaration:#

▸ (width: number, height: number): Promise<void>

Parameters:#

NameType
widthnumber
heightnumber

Returns: Promise<void>

Defined in: packages/mugshot/src/interfaces/webdriver.ts:39

Defined in: packages/mugshot/src/interfaces/webdriver.ts:39


takeViewportScreenshot#

takeViewportScreenshot: () => Promise<string>

Take a viewport screenshot and return a base64 string.

see https://w3c.github.io/webdriver/#take-screenshot

Type declaration:#

▸ (): Promise<string>

Returns: Promise<string>

Defined in: packages/mugshot/src/interfaces/webdriver.ts:13

Defined in: packages/mugshot/src/interfaces/webdriver.ts:13