UNPKG

playwright-fluent

Version:
759 lines (758 loc) 34 kB
import { Browser, Dialog, Frame, Page, Request } from 'playwright'; import { BrowserName, CheckOptions, ClearTextOptions, ClickOptions, CloseOptions, DateFormat, DateTimeFormatOptions, DoubleClickOptions, FluentMock, HarRequestResponseOptions, HoverOptions, InvokeOptions, KeyboardHoldKey, KeyboardKey, KeyboardPressOptions, LaunchOptions, MethodName, MockedResponse, NavigationOptions, PasteTextOptions, Point, RequestInterceptionFilterOptions, ScreenshotOptions, SelectOptionInfo, SelectOptions, SwitchToIframeOptions, TypeTextOptions, WindowState, WithMocksOptions } from '../actions'; import { DeviceName, ViewportOptions, ViewportSize, WindowSize, WindowSizeOptions } from '../devices'; import { SelectorFluent } from '../selector-api'; import { HarData, HttpHeaders, WaitOptions, WaitUntilOptions } from '../utils'; import { Geolocation, HarOptions, Permission, RecordVideoOptions, StorageState } from './playwright-types'; import { TimeZoneId } from './timezone-ids'; export { BrowserName, CheckOptions, ClearTextOptions, ClickOptions, CloseOptions, DateFormat, DateTimeFormatOptions, defaultMocksOptions, DoubleClickOptions, FluentMock, generateCodeForMissingMock, getMissingMocks, getOutdatedMocks, HarRequestResponseOptions, HoverOptions, InvokeOptions, KeyboardHoldKey, KeyboardKey, KeyboardPressOptions, LaunchOptions, MethodName, MissingMock, MockedResponse, mockGetWithEmptyResponseAndStatus, mockGetWithForbiddenResponse, mockGetWithJavascriptResponse, mockGetWithJsonResponse, mockGetWithJsonResponseDependingOnQueryString, mockGetWithUnauthorizedResponse, mockPostWithEmptyResponseAndStatus, NavigationOptions, PasteTextOptions, Point, RequestInfos, RequestInterceptionFilterOptions, ResponseData, ScreenshotOptions, SelectOptionInfo, SelectOptions, SerializableDOMRect, SwitchToIframeOptions, TypeTextOptions, validateMock, WindowState, } from '../actions'; export { allKnownDevices, Device, DeviceName, sizeOf, Viewport, ViewportOptions, ViewportSize, WindowSize, WindowSizeOptions, } from '../devices'; export { defaultWaitUntilOptions, getHarDataFrom, getHarResponseContentAs, getHarResponseFor, HarData, HarEntryParserOptions, harHeadersToHttpHeaders, HttpHeaders, noWaitNoThrowOptions, uniqueFilename, userDownloadsDirectory, userHomeDirectory, WaitOptions, WaitUntilOptions, } from '../utils'; export { BrowserContextOptions, Geolocation, HarOptions, Permission, RecordVideoOptions, StorageState, } from './playwright-types'; export { TimeZoneId } from './timezone-ids'; export interface AssertOptions { /** * Defaults to 30000 milliseconds. * * @type {number} * @memberof AssertOptions */ timeoutInMilliseconds: number; /** * time during which the Assert must give back the same result. * Defaults to 300 milliseconds. * You must not setup a duration < 100 milliseconds. * @type {number} * @memberof AssertOptions */ stabilityInMilliseconds: number; /** * Will generate 'debug' logs, * so that you can understand why the assertion does not give the expected result. * Defaults to false * @type {boolean} * @memberof AssertOptions */ verbose: boolean; } export declare const defaultAssertOptions: AssertOptions; export type Story = (p: PlaywrightFluent) => Promise<void>; export type StoryWithProps<T> = (p: PlaywrightFluent, props: T) => Promise<void>; export type AsyncFunc = () => Promise<string | number | boolean | undefined | null>; export interface AsyncFuncExpectAssertion { resolvesTo: (value: string | number | boolean | undefined | null, options?: Partial<AssertOptions>) => PlaywrightFluent; } export interface ExpectAssertion { doesNotHaveClass: (className: string, options?: Partial<AssertOptions>) => PlaywrightFluent; doesNotExist: (options?: Partial<AssertOptions>) => PlaywrightFluent; exists: (options?: Partial<AssertOptions>) => PlaywrightFluent; hasAttributeWithValue: (attrbuteName: string, attributeValue: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasClass: (className: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasExactValue: (value: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasFocus: (options?: Partial<AssertOptions>) => PlaywrightFluent; hasPlaceholder: (text: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasText: (text: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasValue: (value: string, options?: Partial<AssertOptions>) => PlaywrightFluent; isChecked: (options?: Partial<AssertOptions>) => PlaywrightFluent; isDisabled: (options?: Partial<AssertOptions>) => PlaywrightFluent; isEnabled: (options?: Partial<AssertOptions>) => PlaywrightFluent; isNotVisible: (options?: Partial<AssertOptions>) => PlaywrightFluent; isNotVisibleInViewport: (options?: Partial<AssertOptions>) => PlaywrightFluent; isReadOnly: (options?: Partial<AssertOptions>) => PlaywrightFluent; isUnchecked: (options?: Partial<AssertOptions>) => PlaywrightFluent; isVisible: (options?: Partial<AssertOptions>) => PlaywrightFluent; isVisibleInViewport: (options?: Partial<AssertOptions>) => PlaywrightFluent; } export type DialogType = 'alert' | 'confirm' | 'prompt' | 'beforeunload'; export interface ExpectDialogAssertion { hasMessage: (message: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasValue: (value: string, options?: Partial<AssertOptions>) => PlaywrightFluent; hasExactValue: (value: string, options?: Partial<AssertOptions>) => PlaywrightFluent; isOfType: (dialogType: DialogType, options?: Partial<AssertOptions>) => PlaywrightFluent; } export interface TracingOptions { /** * If specified, the trace is going to be saved into the file with the given name inside the `tracesDir` folder */ name?: string; /** * folder where the trace(s) will be saved */ tracesDir?: string; /** * Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. */ screenshots?: boolean; /** * Whether to capture DOM snapshot on every action. */ snapshots?: boolean; /** * Whether to include source files for trace actions. */ sources?: boolean; /** * Trace name to be shown in the Trace Viewer. */ title?: string; } export interface StartTracingOptions { /** * Trace name to be shown in the Trace Viewer. */ title?: string; } export interface StopTracingOptions { /** * Export trace collected since the last * [tracing.startChunk([options])](https://playwright.dev/docs/api/class-tracing#tracing-start-chunk) call into the file * with the given path. */ path?: string; } export declare const defaultTracingOptions: TracingOptions; export declare class PlaywrightFluent implements PromiseLike<void> { then<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>; private _lastError?; lastError(): Error | undefined; private executeActions; constructor(browser?: Browser, pageOrFrame?: Page | Frame | null); private browser; private browserContext; currentBrowser(): Browser | undefined; private dialog; private _isDialogOpened; isDialogOpened(): boolean; private _isDialogClosed; isDialogClosed(): boolean; currentDialog(): Dialog | undefined; private page; currentPage(): Page | undefined; private frame; currentFrame(): Frame | undefined; /** * When execution context is a frame it will returns the current playwright Frame object, * otherwise it returns the current playwright Page object * * @returns {(Page | Frame | undefined)} * @memberof PlaywrightFluent */ currentPageOrFrame(): Page | Frame | undefined; private _previousPage; previousPage(): Page | undefined; private _hasBeenRedirectedToAnotherTab; hasBeenRedirectedToAnotherTab(): boolean; private _context; /** * Private context object you can use to store data shared between any steps at runtime * * @readonly * @type {unknown} * @memberof PlaywrightFluent */ get context(): unknown; /** * Private typed context object you can use to store data shared between any steps at runtime * * @readonly * @type {unknown} * @memberof PlaywrightFluent */ contextAs<T>(): T; private actions; private launchOptions; private defaultWaitOptions; private defaultAssertOptions; private buildAssertOptionsFrom; private contextOptions; private emulatedDevice; private customWindowSize; private customWindowSizeOptions; private showMousePosition; private handleDialogs; private handleTracing; private tracingOptions; private enableTracingOnBrowserContext; private launchBrowser; private gotoPreviousTab; withDefaultWaitOptions(options: Partial<WaitOptions>): PlaywrightFluent; withDefaultAssertOptions(options: Partial<AssertOptions>): PlaywrightFluent; withOptions(options: Partial<LaunchOptions>): PlaywrightFluent; withWindowSize(size: WindowSize, options?: Partial<WindowSizeOptions>): PlaywrightFluent; withViewport(viewport: ViewportSize, options?: Partial<ViewportOptions>): PlaywrightFluent; withBrowser(name: BrowserName): PlaywrightFluent; withGeolocation(location: Geolocation): PlaywrightFluent; withTimezone(timezoneId: TimeZoneId): PlaywrightFluent; withExtraHttpHeaders(headers: HttpHeaders): PlaywrightFluent; ignoreHttpsErrors(): PlaywrightFluent; withPermissions(...permissions: Permission[]): PlaywrightFluent; withStorageState(storageStateFile: string | StorageState): PlaywrightFluent; /** * Show mouse position with a non intrusive cursor * * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ withCursor(): PlaywrightFluent; /** * Subscribe to page Dialogs events, so that you can act and assert on opened dialogs. * * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ WithDialogs(): PlaywrightFluent; /** * Enable tracing API. * Playwright should be installed with a version >= 1.12.0 * * @param {Partial<TracingOptions>} [options] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * @example * const p = new PlaywrightFluent(); * const tracePath = path.join(__dirname, 'trace1.zip'); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .withTracing() * .startTracing({title: 'my first trace'}) * .navigateTo(url) * ... * .stopTracingAndSaveTrace({path: tracePath}) * .close(); * */ withTracing(options?: Partial<TracingOptions>): PlaywrightFluent; private startTracingChunk; private stopTracingChunk; /** * Start a new trace chunk. * You must first enable tracing by calling the .withTrace() method. * * @param {Partial<StartTracingOptions>} [options] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * @example * const p = new PlaywrightFluent(); * const tracePath = path.join(__dirname, 'trace1.zip'); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .withTracing() * .startTracing({title: 'my first trace'}) * .navigateTo(url) * ... * .stopTracingAndSaveTrace({path: tracePath}) * .close(); * */ startTracing(options?: Partial<StartTracingOptions>): PlaywrightFluent; /** * Stop the trace chunk and store the trace file to the specified path. * * @param {Partial<StopTracingOptions>} [options] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * @example * const p = new PlaywrightFluent(); * const tracePath = path.join(__dirname, 'trace1.zip'); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .withTracing() * .startTracing({title: 'my first trace'}) * .navigateTo(url) * ... * .stopTracingAndSaveTrace({path: tracePath}) * .close(); */ stopTracingAndSaveTrace(options?: Partial<StopTracingOptions>): PlaywrightFluent; /** * Enables HAR recording for all pages. * Network activity will be saved into options.path file. * If not specified, the HAR is not recorded. * Make sure to await browserContext.close() for the HAR to be saved. * * @param {HarOptions} options * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * @example * const p = new PlaywrightFluent(); * const harFilepath = `${path.join(__dirname, uniqueFilename({ prefix: 'har-', extension: '.json' }))}`; * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .recordNetworkActivity({ path: harFilepath }) * ... * .close(); * * const harData = p.getRecordedNetworkActivity(); * */ recordNetworkActivity(options: HarOptions): PlaywrightFluent; /** * Enables video recording into the options.dir directory. * If not specified videos are not recorded. * Make sure to await browserContext.close() for videos to be saved. * * @param {RecordVideoOptions} options * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * * @example * const p = new PlaywrightFluent(); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withWindowSize(sizeOf._1024x768) * .clearVideoFilesOlderThan(__dirname, 60) * .recordVideo({ dir: __dirname, size: sizeOf._1024x768 }) * .navigateTo(url) * ... * .close(); * * const videoPath = await p.getRecordedVideoPath(); */ recordVideo(options: RecordVideoOptions): PlaywrightFluent; getRecordedVideoPath(): Promise<string | undefined>; private clearVideoFiles; /** * Remove video files generated by previous tests run * * @param {string} dir * @param {number} durationInSeconds * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ clearVideoFilesOlderThan(dir: string, durationInSeconds: number): PlaywrightFluent; /** * Get HAR data as json data. * Call this method only after the browser is closed. * @param {string} [filepath] optional * @returns {HarData} * @memberof PlaywrightFluent */ getRecordedNetworkActivity(filepath?: string): HarData; private closeBrowser; close(options?: Partial<CloseOptions>): PlaywrightFluent; switchToPreviousTab(): PlaywrightFluent; private sentRequests; getRecordedRequestsTo(url: string): Request[]; getLastRecordedRequestTo(url: string): Request | undefined; clearRecordedRequestsTo(url: string): void; private recordRequestsToUrl; /** * Will track and record requests whose url contains the input url. * Usefull when you need to check what the front sends to the back and/or what the back sends to the front. * Each recorded request is a standard `playwright` request object that contains both the request and the response. * * @param {string} partialUrl This parameter should be seen as a partial url (it is not a regex and not a glob pattern). * @param {(request: Request) => boolean} [ignorePredicate=() => false] optional predicate to provide if you want to ignore specific requests * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * @example * const p = new PlaywrightFluent(); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .recordRequestsTo('/api/v1/user', (request) => request.method() === 'OPTIONS') * .recordRequestsTo('/api/v1/books') * .navigateTo(url); */ recordRequestsTo(partialUrl: string, ignorePredicate?: (request: Request) => boolean): PlaywrightFluent; private recordDownloadsToDirectory; /** * Save all downloads in directory. * * @param {string} directory * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * * @example * const p = new PlaywrightFluent(); * const expectedDownloadedFilepath = path.join(userDownloadsDirectory, 'download.zip'); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .recordDownloadsTo(userDownloadsDirectory) * .navigateTo(url) * .click('a#download-package') * .waitUntil(async () => fileExists(expectedDownloadedFilepath)); */ recordDownloadsTo(directory: string): PlaywrightFluent; private delayRequestsToUrl; delayRequestsTo(partialUrl: string, delayInSeconds: number): PlaywrightFluent; private onRequestToRespondWith; private onRequestToRespondFromHar; onRequestTo(partialUrl: string, options?: Partial<RequestInterceptionFilterOptions>): { respondWith: <T>(response: Partial<MockedResponse<T>> | ((request: Request) => Partial<MockedResponse<T>>)) => PlaywrightFluent; respondFromHar: (harFiles: string[], options?: Partial<HarRequestResponseOptions>) => PlaywrightFluent; }; private failedRequests; getFailedRequests(): Request[]; clearFailedRequests(): void; private recordAllFailedRequests; recordFailedRequests(): PlaywrightFluent; private pageErrors; getPageErrors(): Error[]; clearPageErrors(): void; private recordUncaughtExceptions; recordPageErrors(): PlaywrightFluent; private saveStorageStateToFile; /** * Will save the storage state in a local file * * @param {string} targetFile : The file path to save the storage state to. If path is a relative path, then it is resolved relative to current working directory * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ saveStorageStateTo(targetFile: string): PlaywrightFluent; /** * Get current Playwright Storage State * * @returns {(Promise<StorageState | undefined>)} * @memberof PlaywrightFluent */ currentStorageState(): Promise<StorageState | undefined>; private pauseExecution; pause(): PlaywrightFluent; private waitForDialogToOpen; /** * Wait for a dialog to open. * * @param {Partial<WaitUntilOptions>} [options={}] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ waitForDialog(options?: Partial<WaitUntilOptions>): PlaywrightFluent; private cancelCurrentDialog; cancelDialog(): PlaywrightFluent; private acceptCurrentDialog; acceptDialog(): PlaywrightFluent; private typeTextInCurrentDialogAndSubmit; typeTextInDialogAndSubmit(text: string): PlaywrightFluent; private _mocksContext; /** * context shared between all mocks. * * @readonly * @type {unknown} * @memberof PlaywrightFluent */ get mocksContext(): unknown; /** * typed context shared between all mocks. * * @template T * @returns {T} * @memberof PlaywrightFluent */ mocksContextAs<T>(): T; private _allMocks; private registerMocks; /** * Provide a set of mocks in order to automatically handle request interceptions * This method can be called multiple times with different set of mocks: * in this case all mocks are concatenated in a single internal array. * * * @template T * @param {() => Partial<FluentMock<T>[]} mocks * @param {Partial<WithMocksOptions>} [options=defaultMocksOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ withMocks<T = unknown>(mocks: Partial<FluentMock<T>>[], options?: Partial<WithMocksOptions>): PlaywrightFluent; removeMocksWithDisplayName(displayName: string | undefined): PlaywrightFluent; hasMockWithDisplayName(displayName: string | undefined): boolean; /** * Get all mocks with the given displayName * * @param {(string | undefined)} displayName * @return {*} {(Partial<FluentMock>[] | undefined)} * @memberof PlaywrightFluent */ getAllMocksWithDisplayName(displayName: string | undefined): Partial<FluentMock>[] | undefined; /** * Get the last mock with the given displayName * * @param {(string | undefined)} displayName * @return {*} {(Partial<FluentMock> | undefined)} * @memberof PlaywrightFluent */ getLastMockWithDisplayName(displayName: string | undefined): Partial<FluentMock> | undefined; private gotoUrl; navigateTo(url: string, options?: Partial<NavigationOptions>): PlaywrightFluent; private hoverOnSelector; private hoverOnSelectorObject; hover(selector: string | SelectorFluent, options?: Partial<HoverOptions>): PlaywrightFluent; private switchFromSelectorToIframe; private switchFromSelectorObjectToIframe; /** * Will switch inside the iframe targeted by the specified selector * * @param {(string | SelectorFluent)} selector * @param {Partial<SwitchToIframeOptions>} [options] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent * * @example * const p = new PlaywrightFluent(); * const selector = 'iframe'; * const inputInIframe = '#input-inside-iframe'; * const inputInMainPage = '#input-in-main-page'; * await p * .withBrowser('chromium') * .withOptions({ headless: false }) * .withCursor() * .navigateTo(url) * .hover(selector) * .switchToIframe(selector) * .click(inputInIframe) * .typeText('hey I am in the iframe') * .switchBackToPage() * .click(inputInMainPage) * .typeText('hey I am back in the page!'); */ switchToIframe(selector: string | SelectorFluent, options?: Partial<SwitchToIframeOptions>): PlaywrightFluent; private switchBackFromIframeToCurrentPage; /** * Will switch from the current Iframe back to the current page. * * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ switchBackToPage(): PlaywrightFluent; private clickOnSelector; private clickOnSelectorObject; click(selector: string | SelectorFluent, options?: Partial<ClickOptions>): PlaywrightFluent; private doubleClickOnSelector; private doubleClickOnSelectorObject; doubleClick(selector: string | SelectorFluent, options?: Partial<DoubleClickOptions>): PlaywrightFluent; private clickAtPositionOnPage; clickAtPosition(position: Point, options?: Partial<ClickOptions>): PlaywrightFluent; private checkSelector; private checkSelectorObject; check(selector: string | SelectorFluent, options?: Partial<CheckOptions>): PlaywrightFluent; private uncheckSelector; private uncheckSelectorObject; uncheck(selector: string | SelectorFluent, options?: Partial<CheckOptions>): PlaywrightFluent; private selectOptionsInSelector; private selectOptionsInFocusedSelector; private selectOptionsInSelectorObject; select(...labels: string[]): { in: (selector: string | SelectorFluent, options?: Partial<SelectOptions>) => PlaywrightFluent; inFocused: (options?: Partial<SelectOptions>) => PlaywrightFluent; }; private selectOptionsByValueInFocusedSelector; private selectOptionsByValueInSelector; private selectOptionsByValueInSelectorObject; selectByValue(...values: string[]): { in: (selector: string | SelectorFluent, options?: Partial<SelectOptions>) => PlaywrightFluent; inFocused: (options?: Partial<SelectOptions>) => PlaywrightFluent; }; /** * Emulate device * * @param {DeviceName} deviceName * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ emulateDevice(deviceName: DeviceName): PlaywrightFluent; private typeTextInFocusedElement; /** * Type text in the element that has current focus. * * @param {string} text * @param {Partial<TypeTextOptions>} [options=defaultTypeTextOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ typeText(text: string, options?: Partial<TypeTextOptions>): PlaywrightFluent; private clearTextInFocusedElement; /** * Clear text in the element that has current focus. * * @param {Partial<ClearTextOptions>} [options=defaultClearTextOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ clearText(options?: Partial<ClearTextOptions>): PlaywrightFluent; /** * Alias for clearText. * * @param {Partial<ClearTextOptions>} [options=defaultClearTextOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ clear(options?: Partial<ClearTextOptions>): PlaywrightFluent; private invokeMethodOnSelector; private invokeMethodOnSelectorObject; /** * Be able to invoke a native method on a selector. * Use this action only in edge cases * where the selector itself is hidden because of its transprency, * or because it has null dimension, * and the normal click does not work neither on this selector nor on it's parent. * * @param {MethodName} methodName * @param {(string | SelectorFluent)} selector * @param {Partial<InvokeOptions>} [options] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ invokeMethod(methodName: MethodName, selector: string | SelectorFluent, options?: Partial<InvokeOptions>): PlaywrightFluent; private pasteTextInFocusedElement; /** * Paste text in the element that has current focus. * * @param {string} text * @param {Partial<PasteTextOptions>} [options=defaultPasteTextOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ pasteText(text: string, options?: Partial<PasteTextOptions>): PlaywrightFluent; private pressOnKey; pressKey(key: KeyboardKey, options?: Partial<KeyboardPressOptions>): PlaywrightFluent; private holdKey; holdDownKey(key: KeyboardHoldKey): PlaywrightFluent; private releaseHoldKey; releaseKey(key: KeyboardHoldKey): PlaywrightFluent; wait(durationInMilliseconds: number): PlaywrightFluent; takeFullPageScreenshotAsBase64(options?: Partial<ScreenshotOptions>): Promise<string>; private registerStory; runStory<T>(story: Story | StoryWithProps<T>, param?: T): PlaywrightFluent; attemptsTo<T>(story: Story | StoryWithProps<T>, param?: T): PlaywrightFluent; and<T>(story: Story | StoryWithProps<T>, param?: T): PlaywrightFluent; do<T>(story: Story | StoryWithProps<T>, param?: T): PlaywrightFluent; verifyIf<T>(story: Story | StoryWithProps<T>, param?: T): PlaywrightFluent; /** * Wait until predicate becomes true, * and always return true during 300 ms. * The waiting mechanism can be modified by setting options * * @param {() => Promise<boolean>} predicate * @param {Partial<WaitUntilOptions>} [options=defaultWaitUntilOptions] * @param {(string | (() => Promise<string>))} errorMessage * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ waitUntil(predicate: () => Promise<boolean>, options?: Partial<WaitUntilOptions>, errorMessage?: string | (() => Promise<string>)): PlaywrightFluent; /** * Waits until the function getValue() returns the same result during 300 ms. * The waiting mechanism can be modified by setting options * * @param {(() => Promise<string | boolean | number | null | undefined>)} getValue * @param {Partial<WaitUntilOptions>} [options=defaultWaitUntilOptions] * @returns {PlaywrightFluent} * @memberof PlaywrightFluent */ waitForStabilityOf(getValue: () => Promise<string | boolean | number | null | undefined>, options?: Partial<WaitUntilOptions>): PlaywrightFluent; /** * Get current url. * * If the underlying browser tab has been closed, or the browser context has been closed, or the browser has been closed, it will return the error message provided by Playwright. * @returns {Promise<string>} */ getCurrentUrl(): Promise<string>; getCurrentWindowState(): Promise<WindowState>; getInnerTextOf(selector: string, options?: Partial<WaitUntilOptions>): Promise<string | null | undefined>; getSelectedText(): Promise<string>; /** * Get the today date inside the browser * * @param {(DateFormat | DateTimeFormatOptions)} [format] see more details for DateTimeFormatOptions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#examples * @returns {Promise<string>} * @memberof PlaywrightFluent * * @example * const p = new PlaywrightFluent(); * await p * .withBrowser('chromium') * .withOptions({ headless: true }) * .withCursor() * .withTimezone('Asia/Tokyo') * .navigateTo(url); * * const today = await p.getToday('yyyy-mm-dd'); * const todayInCustomFormat = await p.getToday({ * locale: 'en', * intlOptions: { year: 'numeric', month: 'short', day: 'numeric' }, * }) */ getToday(format?: DateFormat | DateTimeFormatOptions): Promise<string>; getValueOf(selector: string, options?: Partial<WaitUntilOptions>): Promise<string | undefined | null>; getAllOptionsOf(selector: string, options?: Partial<WaitUntilOptions>): Promise<SelectOptionInfo[]>; getSelectedOptionOf(selector: string, options?: Partial<WaitUntilOptions>): Promise<SelectOptionInfo | undefined>; getAllSelectedOptionsOf(selector: string, options?: Partial<WaitUntilOptions>): Promise<SelectOptionInfo[]>; /** * Create a Selector object to be able to target a DOM element * that is embedded in a complex dom hierarchy or dom array * * @param {string} selector * @returns {SelectorFluent} * @memberof PlaywrightFluent */ selector(selector: string): SelectorFluent; hasFocus(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorHasFocus; hasText(selector: string | SelectorFluent, text: string, options?: Partial<WaitUntilOptions>): Promise<boolean>; hasValue(selector: string | SelectorFluent, value: string, options?: Partial<WaitUntilOptions>): Promise<boolean>; hasExactValue(selector: string | SelectorFluent, value: string, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorHasText; private expectThatSelectorHasExactValue; private expectThatSelectorHasValue; private expectThatSelectorHasClass; private expectThatSelectorDoesNotHaveClass; private expectThatSelectorHasPlaceholder; private expectThatSelectorHasAttributeWithValue; private expectThatSelectorExists; private expectThatSelectorDoesNotExist; exists(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; doesNotExist(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsVisible; private expectThatSelectorIsVisibleInViewport; private expectThatSelectorIsNotVisible; private expectThatSelectorIsNotVisibleInViewport; isNotVisible(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; isNotVisibleInViewport(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; isVisible(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; isVisibleInViewport(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsChecked; isChecked(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsUnchecked; isUnchecked(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsEnabled; isEnabled(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsDisabled; isDisabled(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatSelectorIsReadOnly; isReadOnly(selector: string | SelectorFluent, options?: Partial<WaitUntilOptions>): Promise<boolean>; private expectThatAsyncFuncHasResult; expectThatAsyncFunc(func: AsyncFunc): AsyncFuncExpectAssertion; expectThatSelector(selector: string | SelectorFluent): ExpectAssertion; /** * Alias for expectThatSelector() * * @param {(string | SelectorFluent)} selector * @returns {ExpectAssertion} * @memberof PlaywrightFluent */ expectThat(selector: string | SelectorFluent): ExpectAssertion; private expectThatDialogIsOfType; private expectThatDialogHasMessage; private expectThatDialogHasValue; private expectThatDialogHasExactValue; expectThatDialog(): ExpectDialogAssertion; } /** * cast input object as a PlaywrightFluent instance * usefull when such instance is store in an untyped context * @param p : an untyped PlaywrightFluent instance */ export declare const cast: (p: unknown) => PlaywrightFluent;