import { BrowserContextOptions , Geolocation , HarOptions , Permission , RecordVideoOptions , StorageState , } from './playwright-types' ; import { TimeZoneId } from './timezone-ids' ; import * as assertion from '../assertions' ; import * as action from '../actions' ; import { BrowserName , CheckOptions , ClearTextOptions , ClickOptions , CloseOptions , DateFormat , DateTimeFormatOptions , defaultCheckOptions , defaultClearTextOptions , defaultClickOptions , defaultCloseOptions , defaultDoubleClickOptions , defaultFullPageScreenshotOptions , defaultHarRequestResponseOptions , defaultHoverOptions , defaultInvokeOptions , defaultKeyboardPressOptions , defaultLaunchOptions , defaultMocksOptions , defaultNavigationOptions , defaultPasteTextOptions , defaultSelectOptions , defaultSwitchToIframeOptions , defaultTypeTextOptions , DoubleClickOptions , FluentMock , HarRequestResponseOptions , HoverOptions , InvokeOptions , KeyboardHoldKey , KeyboardKey , KeyboardPressOptions , LaunchOptions , MethodName , MockedResponse , NavigationOptions , PasteTextOptions , Point , RequestInterceptionFilterOptions , ScreenshotOptions , SelectOptionInfo , SelectOptions , SwitchToIframeOptions , TypeTextOptions , validateMock , WindowState , WithMocksOptions , } from '../actions' ; import { allKnownDevices , defaultWindowSizeOptions , Device , DeviceName , getBrowserArgsForDevice , getDevice , WindowSize , WindowSizeOptions , getBrowserArgsForWindowSize , ViewportSize , ViewportOptions , defaultViewportOptions , } from '../devices' ; import { defaultWaitUntilOptions , deleteFile , getFilesOlderThanInDirectory , HarData , getHarDataFrom , sleep , toFrame , toPage , waitForStabilityOf , WaitOptions , waitUntil , WaitUntilOptions , HttpHeaders , } from '../utils' ; import { SelectorFluent } from '../selector-api' ; import { Request , Browser , Page , BrowserContext , Frame , Dialog } from 'playwright' ; const isCI = require ( 'is-ci' ) as boolean ; export { defaultWaitUntilOptions , getHarDataFrom , getHarResponseContentAs , getHarResponseFor , HarData , HarEntryParserOptions , harHeadersToHttpHeaders , HttpHeaders , noWaitNoThrowOptions , uniqueFilename , userDownloadsDirectory , userHomeDirectory , WaitOptions , WaitUntilOptions , } from '../utils' ; 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 { BrowserContextOptions , Geolocation , HarOptions , Permission , RecordVideoOptions , StorageState , } from './playwright-types' ; export { TimeZoneId } from './timezone-ids' ; export interface AssertOptions { type { number } memberof timeoutInMilliseconds : number ; type { number } memberof stabilityInMilliseconds : number ; type { boolean } memberof verbose : boolean ; } export const defaultAssertOptions = { stabilityInMilliseconds : 300 , timeoutInMilliseconds : 30000 , verbose : false , } ; 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 const defaultTracingOptions = { screenshots : true , snapshots : true , } ; export class PlaywrightFluent implements PromiseLike < void > { public async then < TResult1 = void , TResult2 = never > ( onfulfilled ? , onrejected ? ) { return await this . executeActions ( ) . then ( onfulfilled ) . catch ( onrejected ) ; } private _lastError ? : Error ; public lastError ( ) { return this . _lastError ; } private async executeActions ( ) { try { this . _lastError = undefined ; while ( true ) { if ( this . actions . length === 0 ) { break ; } const action = this . actions . shift ( ) ; action && ( await action ( ) ) ; } } catch ( error ) { this . _lastError = error as Error ; this . actions = [ ] ; throw error ; } finally { this . actions = [ ] ; } } constructor ( browser ? , pageOrFrame ? ) { if ( browser && pageOrFrame ) { this . browser = browser ; this . page = toPage ( pageOrFrame ) ; this . frame = toFrame ( pageOrFrame ) ; } } private browser : Browser | undefined ; private browserContext : BrowserContext | undefined ; public currentBrowser ( ) { return this . browser ; } private dialog : Dialog | undefined ; private _isDialogOpened = false ; public isDialogOpened ( ) { return this . _isDialogOpened ; } private _isDialogClosed = true ; public isDialogClosed ( ) { return this . _isDialogClosed ; } public currentDialog ( ) { return this . dialog ; } private page : Page | undefined ; public currentPage ( ) { return this . page ; } private frame : Frame | undefined ; public currentFrame ( ) { return this . frame ; } returns { ( Page | Frame | undefined ) } memberof public currentPageOrFrame ( ) { if ( this . frame ) { return this . frame ; } return this . page ; } private _previousPage : Page | undefined ; public previousPage ( ) { return this . _previousPage ; } private _hasBeenRedirectedToAnotherTab = false ; public hasBeenRedirectedToAnotherTab ( ) { return this . _hasBeenRedirectedToAnotherTab ; } private _context : unknown = { } ; readonly type { unknown } memberof public get context ( ) : unknown { return this . _context ; } readonly type { unknown } memberof public contextAs < T > ( ) { return this . _context as T ; } private actions : ( ( ) => Promise < void > ) [ ] = [ ] ; private launchOptions : LaunchOptions = defaultLaunchOptions ; private defaultWaitOptions : WaitOptions = { ... defaultWaitUntilOptions , } ; private defaultAssertOptions : AssertOptions = { ... defaultAssertOptions , } ; private buildAssertOptionsFrom ( options ? ) { const fullOptions = { ... this . defaultAssertOptions , ... options , } ; return fullOptions ; } private contextOptions : BrowserContextOptions = { viewport : null , acceptDownloads : true } ; private emulatedDevice : Device | undefined = undefined ; private customWindowSize : WindowSize | undefined = undefined ; private customWindowSizeOptions : WindowSizeOptions = defaultWindowSizeOptions ; private showMousePosition = false ; private handleDialogs = false ; private handleTracing = false ; private tracingOptions : TracingOptions = defaultTracingOptions ; private async enableTracingOnBrowserContext ( ) { if ( ! this . handleTracing ) { return ; } await this . browserContext ?. tracing ?. start ( this . tracingOptions ) ; } private async launchBrowser ( name ) { const contextOptions = { ... this . contextOptions } ; if ( this . emulatedDevice ) { contextOptions . viewport = this . emulatedDevice . viewport ; contextOptions . userAgent = this . emulatedDevice . userAgent ; contextOptions . hasTouch = this . emulatedDevice . hasTouch ; contextOptions . isMobile = name !== 'firefox' && this . emulatedDevice . isMobile ; contextOptions . screen = this . emulatedDevice . screen ; this . launchOptions . args = this . launchOptions . args || [ ] ; this . launchOptions . args . push ( ... getBrowserArgsForDevice ( this . emulatedDevice ) . andBrowser ( name ) ) ; } if ( this . customWindowSize ) { this . launchOptions . args = this . launchOptions . args || [ ] ; this . launchOptions . args . push ( ... getBrowserArgsForWindowSize ( this . customWindowSize , this . customWindowSizeOptions ) . andBrowser ( name ) ) ; } if ( this . handleTracing && this . tracingOptions && this . tracingOptions . tracesDir ) { this . launchOptions . tracesDir = this . tracingOptions . tracesDir ; } this . browser = await action . launchBrowser ( name , this . launchOptions ) ; this . browserContext = await this . browser . newContext ( contextOptions ) ; await this . enableTracingOnBrowserContext ( ) ; this . browserContext . on ( 'page' , async ( p ) => { this . _previousPage = this . page ; this . page = p ; this . _hasBeenRedirectedToAnotherTab = true ; try { await p . waitForLoadState ( ) ; } catch ( error ) { } } ) ; this . page = await this . browserContext . newPage ( ) ; if ( this . showMousePosition ) { await action . showMousePosition ( this . page ) ; } if ( this . handleDialogs ) { await action . recordPageDialogs ( this . page , ( dialog ) => { this . dialog = dialog ; this . _isDialogOpened = true ; this . _isDialogClosed = false ; } ) ; } } private async gotoPreviousTab ( ) { if ( ! this . _previousPage ) { return ; } await this . _previousPage . bringToFront ( ) ; const from = this . _previousPage ; this . _previousPage = this . page ; this . page = from ; this . _hasBeenRedirectedToAnotherTab = true ; } public withDefaultWaitOptions ( options ) { const updatedOptions = { ... this . defaultWaitOptions , ... options , } ; this . defaultWaitOptions = updatedOptions ; return this ; } public withDefaultAssertOptions ( options ) { const updatedOptions = { ... this . defaultAssertOptions , ... options , } ; this . defaultAssertOptions = updatedOptions ; return this ; } public withOptions ( options ) { const updatedOptions = { ... this . launchOptions , ... options , } ; this . launchOptions = updatedOptions ; return this ; } public withWindowSize ( size , options ? ) { const windowSizeOptions = { ... defaultWindowSizeOptions , ... options , } ; this . customWindowSize = size ; this . customWindowSizeOptions = windowSizeOptions ; return this ; } public withViewport ( viewport , options ? ) { const viewportOptions = { ... defaultViewportOptions , ... options , } ; if ( viewportOptions . ciOnly && ! isCI ) { return this ; } this . contextOptions . viewport = viewport ; return this ; } public withBrowser ( name ) { const action = ( ) : Promise < void > => this . launchBrowser ( name ) ; this . actions . push ( action ) ; return this ; } public withGeolocation ( location ) { this . contextOptions . geolocation = location ; return this ; } public withTimezone ( timezoneId ) { this . contextOptions . timezoneId = timezoneId ; return this ; } public withExtraHttpHeaders ( headers ) { this . contextOptions . extraHTTPHeaders = headers ; return this ; } public withPermissions ( ... permissions ) { this . contextOptions . permissions = permissions ; return this ; } public withStorageState ( storageStateFile ) { this . contextOptions . storageState = storageStateFile ; return this ; } returns { PlaywrightFluent } memberof public withCursor ( ) { this . showMousePosition = true ; return this ; } returns { PlaywrightFluent } memberof public WithDialogs ( ) { this . handleDialogs = true ; return this ; } param { Partial < TracingOptions > } options returns { PlaywrightFluent } memberof example public withTracing ( options ? ) { this . handleTracing = true ; this . tracingOptions = { ... this . tracingOptions , ... options , } ; return this ; } private async startTracingChunk ( options ) { await this . browserContext ?. tracing ?. startChunk ( options ) ; } private async stopTracingChunk ( options ) { await this . browserContext ?. tracing ?. stopChunk ( options ) ; } param { Partial < StartTracingOptions > } options returns { PlaywrightFluent } memberof example public startTracing ( options ? ) { const startOptions = { ... options , } ; if ( ! this . handleTracing ) { throw new Error ( 'Cannot start Tracing because Tracing is not enabled. Maybe you forgot to call the withTrace(options)' ) ; } const action = ( ) : Promise < void > => this . startTracingChunk ( startOptions ) ; this . actions . push ( action ) ; return this ; } param { Partial < StopTracingOptions > } options returns { PlaywrightFluent } memberof example public stopTracingAndSaveTrace ( options ? ) { const stopOptions = { ... options , } ; if ( ! this . handleTracing ) { throw new Error ( 'Cannot stop Tracing and save trace file because Tracing is not enabled. Maybe you forgot to call the withTrace(options)' ) ; } const action = ( ) : Promise < void > => this . stopTracingChunk ( stopOptions ) ; this . actions . push ( action ) ; return this ; } param { HarOptions } options returns { PlaywrightFluent } memberof example public recordNetworkActivity ( options ) { this . contextOptions . recordHar = options ; return this ; } param { RecordVideoOptions } options returns { PlaywrightFluent } memberof example public recordVideo ( options ) { this . contextOptions . recordVideo = options ; return this ; } public async getRecordedVideoPath ( ) { const videoPath = await this . page ?. video ( ) ?. path ( ) ; return videoPath ; } private async clearVideoFiles ( dir , durationInSeconds ) { const files = getFilesOlderThanInDirectory ( dir , durationInSeconds , ( path ) => { return path . endsWith ( '.webm' ) ; } ) ; files . forEach ( ( file ) => { console . warn ( `File '${ file }' is about to be deleted` ) ; deleteFile ( file ) ; } ) ; } param { string } dir param { number } durationInSeconds returns { PlaywrightFluent } memberof public clearVideoFilesOlderThan ( dir , durationInSeconds ) { const action = ( ) : Promise < void > => this . clearVideoFiles ( dir , durationInSeconds ) ; this . actions . push ( action ) ; return this ; } param { string } filepath returns { HarData } memberof public getRecordedNetworkActivity ( filepath ? ) { const harFilePath = filepath || this . contextOptions . recordHar ?. path ; return getHarDataFrom ( harFilePath ) ; } private async closeBrowser ( options ) { await action . closeBrowser ( this . currentBrowser ( ) , options ) ; } public close ( options ? ) { const closeOptions = { ... defaultCloseOptions , ... options , } ; const action = ( ) : Promise < void > => this . closeBrowser ( closeOptions ) ; this . actions . push ( action ) ; return this ; } public switchToPreviousTab ( ) { const action = ( ) : Promise < void > => this . gotoPreviousTab ( ) ; this . actions . push ( action ) ; return this ; } private sentRequests : Request [ ] = [ ] ; public getRecordedRequestsTo ( url ) { return [ ... this . sentRequests . filter ( ( req ) => req . url ( ) . includes ( url ) ) ] ; } public getLastRecordedRequestTo ( url ) { return this . sentRequests . filter ( ( req ) => req . url ( ) . includes ( url ) ) . pop ( ) ; } public clearRecordedRequestsTo ( url ) { this . sentRequests = [ ... this . sentRequests . filter ( ( req ) => ! req . url ( ) . includes ( url ) ) ] ; } private async recordRequestsToUrl ( partialUrl , ignorePredicate ) { await action . recordRequestsTo ( partialUrl , ignorePredicate , this . currentPage ( ) , ( request ) => this . sentRequests . push ( request ) ) ; } param { string } partialUrl param { ( request : Request ) => boolean } ignorePredicate returns { PlaywrightFluent } memberof example public recordRequestsTo ( partialUrl , ignorePredicate = ( ) => false ) { const action = ( ) : Promise < void > => this . recordRequestsToUrl ( partialUrl , ignorePredicate ) ; this . actions . push ( action ) ; return this ; } private async recordDownloadsToDirectory ( directory ) { await action . recordDownloadsTo ( directory , this . currentPage ( ) ) ; } param { string } directory returns { PlaywrightFluent } memberof example public recordDownloadsTo ( directory ) { const action = ( ) : Promise < void > => this . recordDownloadsToDirectory ( directory ) ; this . actions . push ( action ) ; return this ; } private async delayRequestsToUrl ( partialUrl , delayInSeconds ) { await action . delayRequestsTo ( partialUrl , delayInSeconds , this . currentPage ( ) ) ; } public delayRequestsTo ( partialUrl , delayInSeconds ) { const action = ( ) : Promise < void > => this . delayRequestsToUrl ( partialUrl , delayInSeconds ) ; this . actions . push ( action ) ; return this ; } private async onRequestToRespondWith < T > ( partialUrl , options , response ) { await action . onRequestToRespondWith ( partialUrl , options , response , this . currentPage ( ) ) ; } private async onRequestToRespondFromHar ( partialUrl , harFiles , options ) { await action . onRequestToRespondFromHar ( partialUrl , harFiles , this . currentPage ( ) , options ) ; } public onRequestTo ( partialUrl , options = { } ) { return { respondWith : < T > ( response ) : PlaywrightFluent => { const action = ( ) : Promise < void > => this . onRequestToRespondWith ( partialUrl , options , response ) ; this . actions . push ( action ) ; return this ; } , respondFromHar : ( harFiles , options ? ) : PlaywrightFluent => { const harOptions = { ... defaultHarRequestResponseOptions , ... options , } ; const action = ( ) : Promise < void > => this . onRequestToRespondFromHar ( partialUrl , harFiles , harOptions ) ; this . actions . push ( action ) ; return this ; } , } ; } private failedRequests : Request [ ] = [ ] ; public getFailedRequests ( ) { return [ ... this . failedRequests ] ; } public clearFailedRequests ( ) { this . failedRequests = [ ] ; } private async recordAllFailedRequests ( ) { await action . recordFailedRequests ( this . currentPage ( ) , ( request ) => this . failedRequests . push ( request ) ) ; } public recordFailedRequests ( ) { const action = ( ) : Promise < void > => this . recordAllFailedRequests ( ) ; this . actions . push ( action ) ; return this ; } private pageErrors : Error [ ] = [ ] ; public getPageErrors ( ) { return [ ... this . pageErrors ] ; } public clearPageErrors ( ) { this . pageErrors = [ ] ; } private async recordUncaughtExceptions ( ) { await action . recordPageErrors ( this . currentPage ( ) , ( err ) => this . pageErrors . push ( err ) ) ; } public recordPageErrors ( ) { const action = ( ) : Promise < void > => this . recordUncaughtExceptions ( ) ; this . actions . push ( action ) ; return this ; } private async saveStorageStateToFile ( targetFile ) { await this . browserContext ?. storageState ( { path : targetFile } ) ; } param { string } targetFile returns { PlaywrightFluent } memberof public saveStorageStateTo ( targetFile ) { const action = ( ) : Promise < void > => this . saveStorageStateToFile ( targetFile ) ; this . actions . push ( action ) ; return this ; } returns { ( Promise < StorageState | undefined > ) } memberof public async currentStorageState ( ) { return await this . browserContext ?. storageState ( ) ; } private async pauseExecution ( ) { await action . pause ( this . currentPage ( ) ) ; } public pause ( ) { const action = ( ) : Promise < void > => this . pauseExecution ( ) ; this . actions . push ( action ) ; return this ; } private async waitForDialogToOpen ( options ) { await action . waitForDialog ( ( ) => this . dialog , this . currentPage ( ) , options ) ; } param { Partial < WaitUntilOptions > } options returns { PlaywrightFluent } memberof public waitForDialog ( options = { } ) { const waitUntilOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const action = ( ) : Promise < void > => this . waitForDialogToOpen ( waitUntilOptions ) ; this . actions . push ( action ) ; return this ; } private async cancelCurrentDialog ( ) { await action . cancelDialog ( this . dialog , this . currentPage ( ) , ( ) => { this . dialog = undefined ; this . _isDialogClosed = true ; this . _isDialogOpened = false ; } ) ; } public cancelDialog ( ) { const action = ( ) : Promise < void > => this . cancelCurrentDialog ( ) ; this . actions . push ( action ) ; return this ; } private async acceptCurrentDialog ( ) { await action . acceptDialog ( this . dialog , undefined , this . currentPage ( ) , ( ) => { this . dialog = undefined ; this . _isDialogClosed = true ; this . _isDialogOpened = false ; } ) ; } public acceptDialog ( ) { const action = ( ) : Promise < void > => this . acceptCurrentDialog ( ) ; this . actions . push ( action ) ; return this ; } private async typeTextInCurrentDialogAndSubmit ( text ) { await action . acceptDialog ( this . dialog , text , this . currentPage ( ) , ( ) => { this . dialog = undefined ; this . _isDialogClosed = true ; this . _isDialogOpened = false ; } ) ; } public typeTextInDialogAndSubmit ( text ) { const action = ( ) : Promise < void > => this . typeTextInCurrentDialogAndSubmit ( text ) ; this . actions . push ( action ) ; return this ; } private _mocksContext : unknown = { } ; readonly type { unknown } memberof public get mocksContext ( ) : unknown { return this . _mocksContext ; } template T returns { T } memberof public mocksContextAs < T > ( ) { return this . _mocksContext as T ; } private _allMocks : Partial < FluentMock > [ ] = [ ] ; private async registerMocks ( options ) { await action . withMocks ( ( ) => this . _allMocks , ( ) => this . _mocksContext , options , this . currentPage ( ) ) ; } param { ( ) => Partial < FluentMock > [ ] } mocks param { Partial < WithMocksOptions > } options returns { PlaywrightFluent } memberof public withMocks ( mocks , options = defaultMocksOptions ) { mocks . forEach ( validateMock ) ; if ( this . _allMocks . length === 0 ) { const action = ( ) : Promise < void > => this . registerMocks ( options ) ; this . actions . push ( action ) ; } this . _allMocks = this . _allMocks . concat ( mocks ) ; return this ; } public removeMocksWithDisplayName ( displayName ) { this . _allMocks = this . _allMocks . filter ( ( mock ) => mock . displayName !== displayName ) ; return this ; } public hasMockWithDisplayName ( displayName ) { return this . _allMocks . some ( ( mock ) => mock . displayName === displayName ) ; } private async gotoUrl ( url , options ) { await action . navigateTo ( url , options , this . currentPageOrFrame ( ) ) ; } public navigateTo ( url , options ? ) { const navigationOptions = { ... defaultNavigationOptions , ... options , } ; const action = ( ) : Promise < void > => this . gotoUrl ( url , navigationOptions ) ; this . actions . push ( action ) ; return this ; } private async hoverOnSelector ( selector , options ) { await action . hoverOnSelector ( selector , this . currentPageOrFrame ( ) , options ) ; } private async hoverOnSelectorObject ( selector , options ) { await action . hoverOnSelectorObject ( selector , this . currentPageOrFrame ( ) , options ) ; } public hover ( selector , options ? ) { const hoverOptions = { ... defaultHoverOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . hoverOnSelector ( selector , hoverOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . hoverOnSelectorObject ( selector , hoverOptions ) ; this . actions . push ( action ) ; return this ; } } private async switchFromSelectorToIframe ( selector , options ) { this . frame = await action . switchFromSelectorToIframe ( selector , ( ) => this . currentPageOrFrame ( ) , { ... options , injectCursor : this . showMousePosition , } ) ; } private async switchFromSelectorObjectToIframe ( selector , options ) { this . frame = await action . switchFromSelectorObjectToIframe ( selector , ( ) => this . currentPageOrFrame ( ) , { ... options , injectCursor : this . showMousePosition , } ) ; } param { ( string | SelectorFluent ) } selector param { Partial < SwitchToIframeOptions > } options returns { PlaywrightFluent } memberof example public switchToIframe ( selector , options ? ) { const switchToIframeOptions = { ... defaultSwitchToIframeOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . switchFromSelectorToIframe ( selector , switchToIframeOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . switchFromSelectorObjectToIframe ( selector , switchToIframeOptions ) ; this . actions . push ( action ) ; return this ; } } private async switchBackFromIframeToCurrentPage ( ) { this . frame = undefined ; } returns { PlaywrightFluent } memberof public switchBackToPage ( ) { const action = ( ) : Promise < void > => this . switchBackFromIframeToCurrentPage ( ) ; this . actions . push ( action ) ; return this ; } private async clickOnSelector ( selector , options ) { await action . clickOnSelector ( selector , this . currentPageOrFrame ( ) , options ) ; } private async clickOnSelectorObject ( selector , options ) { await action . clickOnSelectorObject ( selector , this . currentPageOrFrame ( ) , options ) ; } public click ( selector , options ? ) { const clickOptions = { ... defaultClickOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . clickOnSelector ( selector , clickOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . clickOnSelectorObject ( selector , clickOptions ) ; this . actions . push ( action ) ; return this ; } } private async doubleClickOnSelector ( selector , options ) { await action . doubleClickOnSelector ( selector , this . currentPageOrFrame ( ) , options ) ; } private async doubleClickOnSelectorObject ( selector , options ) { await action . doubleClickOnSelectorObject ( selector , this . currentPageOrFrame ( ) , options ) ; } public doubleClick ( selector , options ? ) { const doubleClickOptions = { ... defaultDoubleClickOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . doubleClickOnSelector ( selector , doubleClickOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . doubleClickOnSelectorObject ( selector , doubleClickOptions ) ; this . actions . push ( action ) ; return this ; } } private async clickAtPositionOnPage ( position , options ) { await action . clickAtPosition ( position , this . currentPage ( ) , options ) ; } public clickAtPosition ( position , options ? ) { const clickOptions = { ... defaultClickOptions , ... this . defaultWaitOptions , ... options , } ; const action = ( ) : Promise < void > => this . clickAtPositionOnPage ( position , clickOptions ) ; this . actions . push ( action ) ; return this ; } private async checkSelector ( selector , options ) { await action . checkSelector ( selector , this . currentPageOrFrame ( ) , options ) ; } private async checkSelectorObject ( selector , options ) { await action . checkSelectorObject ( selector , this . currentPageOrFrame ( ) , options ) ; } public check ( selector , options ? ) { const checkOptions = { ... defaultCheckOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . checkSelector ( selector , checkOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . checkSelectorObject ( selector , checkOptions ) ; this . actions . push ( action ) ; return this ; } } private async uncheckSelector ( selector , options ) { await action . uncheckSelector ( selector , this . currentPageOrFrame ( ) , options ) ; } private async uncheckSelectorObject ( selector , options ) { await action . uncheckSelectorObject ( selector , this . currentPageOrFrame ( ) , options ) ; } public uncheck ( selector , options ? ) { const checkOptions = { ... defaultCheckOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . uncheckSelector ( selector , checkOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . uncheckSelectorObject ( selector , checkOptions ) ; this . actions . push ( action ) ; return this ; } } private async selectOptionsInSelector ( selector , labels , options ) { await action . selectOptionsInSelector ( selector , labels , this . currentPageOrFrame ( ) , options ) ; } private async selectOptionsInFocusedSelector ( labels , options ) { await action . selectOptionsInFocused ( labels , this . currentPageOrFrame ( ) , options ) ; } private async selectOptionsInSelectorObject ( selector , labels , options ) { await action . selectOptionsInSelectorObject ( selector , labels , this . currentPageOrFrame ( ) , options ) ; } public select ( ... labels ) { return { in : ( selector , options ? ) : PlaywrightFluent => { const selectOptions = { ... defaultSelectOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . selectOptionsInSelector ( selector , labels , selectOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . selectOptionsInSelectorObject ( selector , labels , selectOptions ) ; this . actions . push ( action ) ; return this ; } } , inFocused : ( options ? ) : PlaywrightFluent => { const selectOptions = { ... defaultSelectOptions , ... this . defaultWaitOptions , ... options , } ; const action = ( ) : Promise < void > => this . selectOptionsInFocusedSelector ( labels , selectOptions ) ; this . actions . push ( action ) ; return this ; } , } ; } private async selectOptionsByValueInFocusedSelector ( values , options ) { await action . selectOptionsByValueInFocused ( values , this . currentPageOrFrame ( ) , options ) ; } private async selectOptionsByValueInSelector ( selector , values , options ) { await action . selectOptionsByValueInSelector ( selector , values , this . currentPageOrFrame ( ) , options ) ; } private async selectOptionsByValueInSelectorObject ( selector , values , options ) { await action . selectOptionsByValueInSelectorObject ( selector , values , this . currentPageOrFrame ( ) , options ) ; } public selectByValue ( ... values ) { return { in : ( selector , options ? ) : PlaywrightFluent => { const selectOptions = { ... defaultSelectOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . selectOptionsByValueInSelector ( selector , values , selectOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . selectOptionsByValueInSelectorObject ( selector , values , selectOptions ) ; this . actions . push ( action ) ; return this ; } } , inFocused : ( options ? ) : PlaywrightFluent => { const selectOptions = { ... defaultSelectOptions , ... this . defaultWaitOptions , ... options , } ; const action = ( ) : Promise < void > => this . selectOptionsByValueInFocusedSelector ( values , selectOptions ) ; this . actions . push ( action ) ; return this ; } , } ; } param { DeviceName } deviceName returns { PlaywrightFluent } memberof public emulateDevice ( deviceName ) { const device = getDevice ( deviceName ) ; if ( ! device ) { throw new Error ( `device '${ deviceName }' is unknown. It must be one of : [${ allKnownDevices . map ( ( d ) => d . name ) . join ( ';' ) }] ` ) ; } this . emulatedDevice = device ; return this ; } private async typeTextInFocusedElement ( text , options ) { await action . typeText ( text , this . currentPageOrFrame ( ) , options ) ; } param { string } text param { Partial < TypeTextOptions > } options returns { PlaywrightFluent } memberof public typeText ( text , options ? ) { const typeTextOptions = { ... defaultTypeTextOptions , ... options , } ; const action = ( ) : Promise < void > => this . typeTextInFocusedElement ( text , typeTextOptions ) ; this . actions . push ( action ) ; return this ; } private async clearTextInFocusedElement ( options ) { await action . clearText ( this . currentPageOrFrame ( ) , options ) ; } param { Partial < ClearTextOptions > } options returns { PlaywrightFluent } memberof public clearText ( options ? ) { const clearTextOptions = { ... defaultClearTextOptions , ... options , } ; const action = ( ) : Promise < void > => this . clearTextInFocusedElement ( clearTextOptions ) ; this . actions . push ( action ) ; return this ; } param { Partial < ClearTextOptions > } options returns { PlaywrightFluent } memberof public clear ( options ? ) { return this . clearText ( options ) ; } private async invokeMethodOnSelector ( methodName , selector , options ) { await action . invokeMethodOnSelector ( methodName , selector , this . currentPageOrFrame ( ) , options ) ; } private async invokeMethodOnSelectorObject ( methodName , selector , options ) { await action . invokeMethodOnSelectorObject ( methodName , selector , options ) ; } param { MethodName } methodName param { ( string | SelectorFluent ) } selector param { Partial < InvokeOptions > } options returns { PlaywrightFluent } memberof public invokeMethod ( methodName , selector , options ? ) { const invokeOptions = { ... defaultInvokeOptions , ... this . defaultWaitOptions , ... options , } ; if ( typeof selector === 'string' ) { const action = ( ) : Promise < void > => this . invokeMethodOnSelector ( methodName , selector , invokeOptions ) ; this . actions . push ( action ) ; return this ; } { const action = ( ) : Promise < void > => this . invokeMethodOnSelectorObject ( methodName , selector , invokeOptions ) ; this . actions . push ( action ) ; return this ; } } private async pasteTextInFocusedElement ( text , options ) { await action . pasteText ( text , this . currentPageOrFrame ( ) , options ) ; } param { string } text param { Partial < PasteTextOptions > } options returns { PlaywrightFluent } memberof public pasteText ( text , options ? ) { const pasteTextOptions = { ... defaultPasteTextOptions , ... options , } ; const action = ( ) : Promise < void > => this . pasteTextInFocusedElement ( text , pasteTextOptions ) ; this . actions . push ( action ) ; return this ; } private async pressOnKey ( key , options ) { await action . pressKey ( key , this . currentPageOrFrame ( ) , options ) ; } public pressKey ( key , options ? ) { const pressKeyOptions = { ... defaultKeyboardPressOptions , ... options , } ; const action = ( ) : Promise < void > => this . pressOnKey ( key , pressKeyOptions ) ; this . actions . push ( action ) ; return this ; } private async holdKey ( key ) { await action . holdDownKey ( key , this . currentPageOrFrame ( ) ) ; } public holdDownKey ( key ) { const action = ( ) : Promise < void > => this . holdKey ( key ) ; this . actions . push ( action ) ; return this ; } private async releaseHoldKey ( key ) { await action . releaseKey ( key , this . currentPageOrFrame ( ) ) ; } public releaseKey ( key ) { const action = ( ) : Promise < void > => this . releaseHoldKey ( key ) ; this . actions . push ( action ) ; return this ; } public wait ( durationInMilliseconds ) { this . actions . push ( async ( ) : Promise < void > => await sleep ( durationInMilliseconds ) ) ; return this ; } public async takeFullPageScreenshotAsBase64 ( options ? ) { const screenshotOptions = { ... defaultFullPageScreenshotOptions , ... options , } ; const result = await action . takeFullPageScreenshotAsBase64 ( this . currentPage ( ) , screenshotOptions ) ; return result ; } private registerStory < T > ( story , param ? ) { if ( typeof story !== 'function' ) { throw new Error ( 'Story should be a function' ) ; } if ( param === undefined ) { this . actions . push ( async ( ) : Promise < void > => await ( story as Story ) ( this ) ) ; return this ; } this . actions . push ( async ( ) : Promise < void > => await story ( this , param ) ) ; return this ; } public runStory < T > ( story , param ? ) { return this . registerStory ( story , param ) ; } public attemptsTo < T > ( story , param ? ) { return this . registerStory ( story , param ) ; } public and < T > ( story , param ? ) { return this . registerStory ( story , param ) ; } public do < T > ( story , param ? ) { return this . registerStory ( story , param ) ; } public verifyIf < T > ( story , param ? ) { return this . registerStory ( story , param ) ; } param { ( ) => Promise < boolean > } predicate param { Partial < WaitUntilOptions > } options param { ( string | ( ( ) => Promise < string > ) ) } errorMessage returns { PlaywrightFluent } memberof public waitUntil ( predicate , options = { } , errorMessage ? ) { const waitUntilOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const defaultErrorMessage = `Predicate still resolved to false after ${ waitUntilOptions . timeoutInMilliseconds } ms.` ; const errorMessageOrDefault = errorMessage || defaultErrorMessage ; this . actions . push ( async ( ) : Promise < void > => { await waitUntil ( predicate , errorMessageOrDefault , waitUntilOptions ) ; } ) ; return this ; } param { ( ( ) => Promise < string | boolean | number | null | undefined > ) } getValue param { Partial < WaitUntilOptions > } options returns { PlaywrightFluent } memberof public waitForStabilityOf ( getValue , options ? ) { const waitUntilOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; this . actions . push ( async ( ) : Promise < void > => { const defaultErrorMessage = `Value function could not have a stable result after ${ waitUntilOptions . timeoutInMilliseconds } ms. Use verbose option to get more details.` ; await waitForStabilityOf ( getValue , defaultErrorMessage , waitUntilOptions ) ; } ) ; return this ; } public async getCurrentUrl ( ) { return await action . getCurrentUrl ( this . currentPageOrFrame ( ) ) ; } public async getCurrentWindowState ( ) { return await action . getWindowState ( this . currentPageOrFrame ( ) ) ; } public async getInnerTextOf ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const result = await action . getInnerTextOfSelector ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; return result ; } public async getSelectedText ( ) { const page = this . currentPageOrFrame ( ) ; if ( ! page ) { return '' ; } const selectedText = await page . evaluate ( ( ) => ( document . getSelection ( ) || '' ) . toString ( ) ) ; return selectedText ; } param { ( DateFormat | DateTimeFormatOptions ) } format returns { Promise < string > } memberof example public async getToday ( format ? ) { const page = this . currentPageOrFrame ( ) ; return await action . getToday ( page , format ) ; } public async getValueOf ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const result = await action . getValueOfSelector ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; return result ; } public async getAllOptionsOf ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const result = await action . getAllOptionsOfSelector ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; return result ; } public async getSelectedOptionOf ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const selectOptions = await action . getAllOptionsOfSelector ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; const selectedOption = selectOptions . find ( ( option ) => option . selected ) ; return selectedOption ; } public async getAllSelectedOptionsOf ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultWaitOptions , ... options , } ; const selectOptions = await action . getAllOptionsOfSelector ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; const selectedOptions = selectOptions . filter ( ( option ) => option . selected ) ; return selectedOptions ; } param { string } selector returns { SelectorFluent } memberof public selector ( selector ) { return new SelectorFluent ( selector , this ) ; } public async hasFocus ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . hasFocus ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorHasFocus ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasFocus ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async hasText ( selector , text , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . hasText ( selector , text , this . currentPageOrFrame ( ) , waitOptions ) ; } public async hasValue ( selector , value , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . hasValue ( selector , value , this . currentPageOrFrame ( ) , waitOptions ) ; } public async hasExactValue ( selector , value , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . hasExactValue ( selector , value , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorHasText ( selector , text , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasText ( selector , text , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorHasExactValue ( selector , value , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasExactValue ( selector , value , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorHasValue ( selector , value , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasValue ( selector , value , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorHasClass ( selector , className , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasClass ( selector , className , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorDoesNotHaveClass ( selector , className , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorDoesNotHaveClass ( selector , className , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorHasPlaceholder ( selector , text , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasPlaceholder ( selector , text , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorHasAttributeWithValue ( selector , attributeName , attributeValue , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorHasAttributeWithValue ( selector , attributeName , attributeValue , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorExists ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorDoesExist ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorDoesNotExist ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorDoesNotExist ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async exists ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . doesExist ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } public async doesNotExist ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . doesNotExist ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorIsVisible ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsVisible ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorIsVisibleInViewport ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsVisibleInViewport ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorIsNotVisible ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsNotVisible ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } private async expectThatSelectorIsNotVisibleInViewport ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsNotVisibleInViewport ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isNotVisible ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isNotVisible ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } public async isNotVisibleInViewport ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isNotVisibleInViewport ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } public async isVisible ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isVisible ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } public async isVisibleInViewport ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isVisibleInViewport ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorIsChecked ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsChecked ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isChecked ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isChecked ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorIsUnchecked ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsUnchecked ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isUnchecked ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isUnchecked ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorIsEnabled ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsEnabled ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isEnabled ( selector , options ? ) { const waitOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isEnabled ( selector , this . currentPageOrFrame ( ) , waitOptions ) ; } private async expectThatSelectorIsDisabled ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsDisabled ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isDisabled ( selector , options ? ) { const assertOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isDisabled ( selector , this . currentPageOrFrame ( ) , assertOptions ) ; } private async expectThatSelectorIsReadOnly ( selector , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatSelectorIsReadOnly ( selector , this . currentPageOrFrame ( ) , fullOptions ) ; } public async isReadOnly ( selector , options ? ) { const assertOptions = { ... defaultWaitUntilOptions , ... this . defaultAssertOptions , ... options , } ; return await assertion . isReadOnly ( selector , this . currentPageOrFrame ( ) , assertOptions ) ; } private async expectThatAsyncFuncHasResult ( func , value , options ? ) { const assertOptions = { ... this . defaultAssertOptions , ... options , } ; await assertion . expectThatAsyncFuncHasResult ( func , value , assertOptions ) ; } public expectThatAsyncFunc ( func ) { return { resolvesTo : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatAsyncFuncHasResult ( func , value , options ) ) ; return this ; } , } ; } public expectThatSelector ( selector ) { return { doesNotHaveClass : ( className , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorDoesNotHaveClass ( selector , className , options ) ) ; return this ; } , doesNotExist : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorDoesNotExist ( selector , options ) ) ; return this ; } , exists : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorExists ( selector , options ) ) ; return this ; } , hasAttributeWithValue : ( attributeName , attributeValue , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasAttributeWithValue ( selector , attributeName , attributeValue , options ) ) ; return this ; } , hasClass : ( className , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasClass ( selector , className , options ) ) ; return this ; } , hasExactValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasExactValue ( selector , value , options ) ) ; return this ; } , hasFocus : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasFocus ( selector , options ) ) ; return this ; } , hasPlaceholder : ( text , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasPlaceholder ( selector , text , options ) ) ; return this ; } , hasText : ( text , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasText ( selector , text , options ) ) ; return this ; } , hasValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasValue ( selector , value , options ) ) ; return this ; } , isChecked : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsChecked ( selector , options ) ) ; return this ; } , isUnchecked : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsUnchecked ( selector , options ) ) ; return this ; } , isDisabled : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsDisabled ( selector , options ) ) ; return this ; } , isEnabled : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsEnabled ( selector , options ) ) ; return this ; } , isReadOnly : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsReadOnly ( selector , options ) ) ; return this ; } , isVisible : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsVisible ( selector , options ) ) ; return this ; } , isNotVisible : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsNotVisible ( selector , options ) ) ; return this ; } , isVisibleInViewport : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsVisibleInViewport ( selector , options ) ) ; return this ; } , isNotVisibleInViewport : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsNotVisibleInViewport ( selector , options ) ) ; return this ; } , } ; } param { ( string | SelectorFluent ) } selector returns { ExpectAssertion } memberof public expectThat ( selector ) { return { doesNotHaveClass : ( className , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorDoesNotHaveClass ( selector , className , options ) ) ; return this ; } , doesNotExist : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorDoesNotExist ( selector , options ) ) ; return this ; } , exists : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorExists ( selector , options ) ) ; return this ; } , hasAttributeWithValue : ( attributeName , attributeValue , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasAttributeWithValue ( selector , attributeName , attributeValue , options ) ) ; return this ; } , hasClass : ( className , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasClass ( selector , className , options ) ) ; return this ; } , hasExactValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasExactValue ( selector , value , options ) ) ; return this ; } , hasFocus : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasFocus ( selector , options ) ) ; return this ; } , hasPlaceholder : ( text , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasPlaceholder ( selector , text , options ) ) ; return this ; } , hasText : ( text , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasText ( selector , text , options ) ) ; return this ; } , hasValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorHasValue ( selector , value , options ) ) ; return this ; } , isChecked : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsChecked ( selector , options ) ) ; return this ; } , isUnchecked : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsUnchecked ( selector , options ) ) ; return this ; } , isDisabled : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsDisabled ( selector , options ) ) ; return this ; } , isEnabled : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsEnabled ( selector , options ) ) ; return this ; } , isReadOnly : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsReadOnly ( selector , options ) ) ; return this ; } , isVisible : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsVisible ( selector , options ) ) ; return this ; } , isNotVisible : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsNotVisible ( selector , options ) ) ; return this ; } , isVisibleInViewport : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsVisibleInViewport ( selector , options ) ) ; return this ; } , isNotVisibleInViewport : ( options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatSelectorIsNotVisibleInViewport ( selector , options ) ) ; return this ; } , } ; } private async expectThatDialogIsOfType ( dialogType , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatDialogIsOfType ( ( ) => this . dialog , dialogType , fullOptions ) ; } private async expectThatDialogHasMessage ( message , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatDialogHasMessage ( ( ) => this . dialog , message , fullOptions ) ; } private async expectThatDialogHasValue ( value , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatDialogHasValue ( ( ) => this . dialog , value , fullOptions ) ; } private async expectThatDialogHasExactValue ( value , options ? ) { const fullOptions = this . buildAssertOptionsFrom ( options ) ; await assertion . expectThatDialogHasExactValue ( ( ) => this . dialog , value , fullOptions ) ; } public expectThatDialog ( ) { return { hasMessage : ( message , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatDialogHasMessage ( message , options ) ) ; return this ; } , hasValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatDialogHasValue ( value , options ) ) ; return this ; } , hasExactValue : ( value , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatDialogHasExactValue ( value , options ) ) ; return this ; } , isOfType : ( dialogType , options ? ) : PlaywrightFluent => { this . actions . push ( ( ) => this . expectThatDialogIsOfType ( dialogType , options ) ) ; return this ; } , } ; } } param p export const cast = ( p ) : PlaywrightFluent => { return p as PlaywrightFluent ; } ;