import { Question } from '@serenity-js/core' ; import { AlertPromise , error as errors } from 'selenium-webdriver' ; import { promiseOf } from '../../promiseOf' ; import { BrowseTheWeb } from '../abilities' ; desc example example see Accept see Dismiss see Enter see Wait see {@link @serenity-js/assertions~Ensure} export class ModalDialog { desc A modal dialog window that could be  Accept ed or  Dismiss ed.
     *
     *  If the window was created using [`Window.prompt()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt)
     *  you can use the  {@link @serenity-js/core/lib/screenplay~Interaction} to  Enter with it too.
     *
     *  example see Accept see Dismiss see Enter returns { serenity-js static window ( ) { return Question . about < AlertPromise > ( `the modal dialog window` , actor => BrowseTheWeb . as ( actor ) . alert ( ) ) ; } desc example example see {@link @serenity-js/assertions~Ensure} see Wait returns { serenity-js static hasPoppedUp ( ) { return Question . about < Promise < boolean > > ( `the modal dialog has popped up` , actor => promiseOf ( BrowseTheWeb . as ( actor ) . alert ( ) ) . then ( ( ) => true , error => { return ! ( error instanceof errors . NoSuchAlertError || ( error instanceof errors . WebDriverError && error . message === `can't convert null to object` ) ) ; } ) ) ; } desc example see {@link @serenity-js/assertions~Ensure} see Wait returns { serenity-js static message ( ) { return Question . about < Promise < string > > ( `the modal dialog message` , actor => promiseOf ( BrowseTheWeb . as ( actor ) . alert ( ) . getText ( ) ) ) ; } }