abstractModalDialog
Hierarchy
Implements
- Optional
Index
Methods
staticisPresent
Returns a promise that resolves to
true
when a modal dialog has been handled, so accepted or dismissed. Returnsfalse
for dialogs that haven’t been handled yet.Useful when a JavaScript modal dialog is generated after a delay, e.g. triggered by
setTimeout
.Example usage
import { actorCalled, Wait } from '@serenity-js/core'
import { Ensure, equals, isPresent } from '@serenity-js/assertions'
import { ModalDialog } from '@serenity-js/web'
await actorCalled('Nick').attemptsTo(
ModalDialog.acceptNext(),
Wait.until(ModalDialog, isPresent()),
Ensure.that(ModalDialog.lastDialogState(), equals('accepted')),
)Returns Question<Promise<boolean>>
staticacceptNext
Produces an interaction that invokes ModalDialog.acceptNext.
Returns Interaction
staticacceptNextWithValue
Produces an interaction that invokes ModalDialog.acceptNextWithValue.
Parameters
value: Answerable<string | number>
Returns Interaction
staticdismissNext
Produces an interaction that invokes ModalDialog.dismissNext.
Returns Interaction
staticlastDialogMessage
QuestionAdapter that resolves to ModalDialog.message for the current Page.
Returns QuestionAdapter<string>
staticlastDialogState
QuestionAdapter that resolves to ModalDialog.state for the current Page.
Returns QuestionAdapter<string>
abstractmessage
Returns the message of the last modal dialog handled, or rejects the promise with a LogicError when no modal dialogs have been observed yet.
Returns Promise<string>
Message of the last handled dialog, or a
Promise
rejected with a LogicError when no dialog has been handled yet.
abstractisPresent
Returns a promise that resolves to
true
when a modal dialog has been handled, so either accepted or dismissed. Returnsfalse
for dialogs that haven’t been handled yet.Useful when a JavaScript modal dialog is generated after a delay, e.g. triggered by
setTimeout
.Returns Promise<boolean>
state
Returns
accepted
ordismissed
for dialogs that have been handled, orabsent
for those that haven’t been handled yet.Returns string
Constructors
constructor
Returns ModalDialog
Manages interactions with JavaScript modal dialog windows, triggered by window.alert, window.confirm, or
window.prompt
, and stores theirmessage
so that it can be asserted on once the dialog is handled.Note that in order to make handling modal windows consistent across the various Web integration tools (such as Playwright, Puppeteer, WebdriverIO or Selenium), Serenity/JS works as follows:
Wait.until(ModalDialog, isPresent())
so that you can synchronise your tests with modal dialogs that appear after a delay.Example HTML widget
In the below example widget, clicking on the button results in a confirmation dialog appearing.
Modal dialog gets dismissed by default
Changing modal dialog handler
Learn more