Skip to main content

Class: WebdriverIOAdapter

@mugshot/webdriverio.WebdriverIOAdapter

Adapter over WebdriverIO to be used with WebdriverScreenshotter.

example

import { Mugshot } from 'mugshot';
import { WebdriverIOAdapter } from '@mugshot/webdriverio';
import { remote } from 'webdriverio';
const browser = await remote({
hostname: 'localhost',
capabilities: { browserName: 'chrome' }
});
const mugshot = new Mugshot(
new WebdriverIOAdapter(browser),
'./screenshots'
);

Implements#

Constructors#

constructor#

+ new WebdriverIOAdapter(client: BrowserAsync): WebdriverIOAdapter

Parameters:#

NameTypeDescription
clientBrowserAsyncThe return value from remote().

Returns: WebdriverIOAdapter

Defined in: packages/webdriverio/src/index.ts:53

Methods#

execute#

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

Execute a function in the current page context.

Type parameters:#

NameType
R-
Aany[]

Parameters:#

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

Returns: Promise<R>

Implementation of: Webdriver.execute

Defined in: packages/webdriverio/src/index.ts:107


getElementRect#

getElementRect(selector: string): Promise<null | { height: number ; width: number ; x: number ; y: number }[] | { height: number ; width: number ; x: number ; y: number }>

Get the dimensions and coordinates of an element.

Parameters:#

NameType
selectorstring

Returns: Promise<null | { height: number ; width: number ; x: number ; y: number }[] | { height: number ; width: number ; x: number ; y: number }>

Implementation of: Webdriver.getElementRect

Defined in: packages/webdriverio/src/index.ts:61


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.

Parameters:#

NameType
widthnumber
heightnumber

Returns: Promise<void>

Implementation of: Webdriver.setViewportSize

Defined in: packages/webdriverio/src/index.ts:88


takeViewportScreenshot#

takeViewportScreenshot(): Promise<string>

Take a viewport screenshot and return a base64 string.

Returns: Promise<string>

Implementation of: Webdriver.takeViewportScreenshot

Defined in: packages/webdriverio/src/index.ts:59