/// import type { Browser as PuppeteerBrowser } from "@puppeteer/browsers"; import type { EventEmitter } from "events"; import type { AssertViewCommand, AssertViewElementCommand } from "./commands/types"; import type { BrowserConfig } from "./../config/browser-config"; import type { ExecutionThreadCtx, ExecutionThreadToolCtx } from "../types"; import type { MoveCursorToCommand } from "./commands/moveCursorTo"; import type { OpenAndWaitCommand } from "./commands/openAndWait"; import type { Callstack } from "./history/callstack"; import type { Test, Hook } from "../test-reader/test-object"; import type { CaptureSnapshotOptions, CaptureSnapshotResult } from "./commands/captureDomSnapshot"; import type { Options } from "@testplane/wdio-types"; import type { SaveStateData } from "./commands/saveState"; import type { StateOpts } from "../config/types"; import type { GetStateOptions } from "./commands/getState"; import type { RestoreStateOptions } from "./commands/restoreState"; import type { WaitForStaticToLoadResult } from "./commands/waitForStaticToLoad"; import type { CDP } from "./cdp"; export declare const BrowserName: { readonly CHROME: PuppeteerBrowser.CHROME; readonly CHROMIUM: PuppeteerBrowser.CHROMIUM; readonly CHROMEHEADLESSSHELL: PuppeteerBrowser.CHROMEHEADLESSSHELL; readonly FIREFOX: PuppeteerBrowser.FIREFOX; readonly SAFARI: "safari"; readonly EDGE: "MicrosoftEdge"; }; export type W3CBrowserName = Exclude<(typeof BrowserName)[keyof typeof BrowserName], typeof BrowserName.CHROMIUM>; export interface BrowserMeta { pid: number; browserVersion: string; [name: string]: unknown; } export interface Browser { publicAPI: WebdriverIO.Browser; config: BrowserConfig; state: Record; applyState: (state: Record) => void; callstackHistory: Callstack; customCommands: { name: string; elementScope: boolean; }[]; } export interface SessionOptions { sessionId: string; sessionCaps?: WebdriverIO.Capabilities; sessionOpts?: Options.WebdriverIO & { capabilities: WebdriverIO.Capabilities; }; driverPid?: number; } type FunctionProperties = Exclude<{ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never; }[keyof T], undefined>; type EventEmitterMethod = FunctionProperties; declare global { namespace WebdriverIO { type BrowserCommand = Exclude, EventEmitterMethod>; type ElementCommand = Exclude, EventEmitterMethod>; type OverwriteCommandFn any> = (this: ThisArg, origCommand: OmitThisParameter, ...args: Parameters) => ReturnType; interface Browser { getMeta(this: WebdriverIO.Browser): Promise; getMeta(this: WebdriverIO.Browser, key: string): Promise; setMeta(this: WebdriverIO.Browser, key: string, value: unknown): Promise; addTag(this: WebdriverIO.Browser, tag: string | string[]): Promise; extendOptions(this: WebdriverIO.Browser, opts: { [name: string]: unknown; }): Promise; getConfig(this: WebdriverIO.Browser): Promise; saveState(options?: StateOpts): Promise; restoreState(options?: RestoreStateOptions): Promise; getState(options?: GetStateOptions): Promise; overwriteCommand(name: CommandName, func: OverwriteCommandFn, attachToElement?: false, proto?: Record, // eslint-disable-line @typescript-eslint/no-explicit-any instances?: Record): void; overwriteCommand(name: CommandName, func: OverwriteCommandFn, attachToElement: true, proto?: Record, // eslint-disable-line @typescript-eslint/no-explicit-any instances?: Record): void; /** * Takes a screenshot of the passed selector and compares the received screenshot with the reference. * * @remarks * For more details, see {@link https://github.com/gemini-testing/testplane#assertview documentation}. * * @example * ```ts * * it('some test', async function() { * await this.browser.url('some/url'); * await this.browser.assertView('plain', '.button', { * ignoreElements: ['.link'], * tolerance: 3.0, * antialiasingTolerance: 4, * allowViewportOverflow: true, * captureElementFromTop: true, * compositeImage: true, * screenshotDelay: 600, * cropMargins: { top: 2, right: 4, bottom: 2, left: 4 }, * selectorToScroll: '.modal' * }); *}); * ``` * * @param state state name, should be unique within one test * @param selectors DOM-node selector that you need to capture * @param opts additional options, currently available: * "ignoreElements", "tolerance", "antialiasingTolerance", "allowViewportOverflow", "captureElementFromTop", * "compositeImage", "screenshotDelay", "cropMargins", "selectorToScroll" */ assertView: AssertViewCommand; /** * Command that allows to add human-readable description for commands in history * * @remarks * For more details, see {@link https://github.com/gemini-testing/testplane#runstep documentation} * * @example * ```ts * it('some test', async function () { * await this.browser.runStep('step name', async () => { * await this.browser.url('some/url'); * ... * }); * }) * ``` * * @param stepName step name * @param stepCb step callback * @returns {Promise} value, returned by `stepCb` */ runStep(this: WebdriverIO.Browser, stepName: string, stepCb: () => Promise | T): Promise; executionContext: (Test | Hook) & { testplaneCtx: ExecutionThreadToolCtx; /** * @deprecated Use `testplaneCtx` instead */ hermioneCtx: ExecutionThreadToolCtx; ctx: ExecutionThreadCtx; }; openAndWait: OpenAndWaitCommand; switchToRepl: (this: WebdriverIO.Browser, ctx?: Record) => Promise; clearSession: (this: WebdriverIO.Browser) => Promise; waitForStaticToLoad: (this: WebdriverIO.Browser, opts?: { timeout?: number; interval?: number; }) => Promise; unstable_captureDomSnapshot(this: WebdriverIO.Browser, options?: Partial): Promise; unstable_captureDomSnapshot(this: WebdriverIO.Browser, selector: string, options?: Partial): Promise; unstable_getCdp(this: WebdriverIO.Browser): Promise; } interface Element { /** * Takes a screenshot of the element and compares the received screenshot with the reference. * * @remarks * For more details, see {@link https://github.com/gemini-testing/testplane#assertview documentation}. * * @example * ```ts * * it('some test', async function() { * await this.browser.url('some/url'); * const button = await this.browser.$('.button'); * await button.assertView('plain', { * ignoreElements: ['.link'], * tolerance: 3.0, * antialiasingTolerance: 4, * allowViewportOverflow: true, * captureElementFromTop: true, * compositeImage: true, * screenshotDelay: 600, * cropMargins: { top: 2, right: 4, bottom: 2, left: 4 }, * selectorToScroll: '.modal' * }); *}); * ``` * * @param state state name, should be unique within one test * @param opts additional options, currently available: * "ignoreElements", "tolerance", "antialiasingTolerance", "allowViewportOverflow", "captureElementFromTop", * "compositeImage", "screenshotDelay", "cropMargins", "selectorToScroll" */ assertView: AssertViewElementCommand; moveCursorTo: MoveCursorToCommand; unstable_captureDomSnapshot(this: WebdriverIO.Element, options?: Partial): Promise; } } } export {};