@serenity-js/web 3.24.1 → 3.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/lib/errors/BrowserWindowClosedError.d.ts +2 -2
- package/lib/errors/BrowserWindowClosedError.js +2 -2
- package/lib/errors/CookieMissingError.d.ts +2 -2
- package/lib/errors/CookieMissingError.js +2 -2
- package/lib/errors/ModalDialogObstructsScreenshotError.d.ts +3 -3
- package/lib/errors/ModalDialogObstructsScreenshotError.js +3 -3
- package/lib/expectations/isActive.d.ts +8 -8
- package/lib/expectations/isActive.js +8 -8
- package/lib/expectations/isClickable.d.ts +8 -8
- package/lib/expectations/isClickable.js +8 -8
- package/lib/expectations/isEnabled.d.ts +8 -8
- package/lib/expectations/isEnabled.js +8 -8
- package/lib/expectations/isSelected.d.ts +8 -8
- package/lib/expectations/isSelected.js +8 -8
- package/lib/expectations/isVisible.d.ts +8 -8
- package/lib/expectations/isVisible.js +8 -8
- package/lib/screenplay/abilities/BrowseTheWeb.d.ts +25 -23
- package/lib/screenplay/abilities/BrowseTheWeb.d.ts.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWeb.js +25 -23
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +1 -1
- package/lib/screenplay/interactions/Clear.d.ts +7 -7
- package/lib/screenplay/interactions/Clear.js +7 -7
- package/lib/screenplay/interactions/Click.d.ts +5 -5
- package/lib/screenplay/interactions/Click.js +5 -5
- package/lib/screenplay/interactions/DoubleClick.d.ts +5 -5
- package/lib/screenplay/interactions/DoubleClick.js +5 -5
- package/lib/screenplay/interactions/Enter.d.ts +5 -5
- package/lib/screenplay/interactions/Enter.js +5 -5
- package/lib/screenplay/interactions/ExecuteScript.d.ts +19 -19
- package/lib/screenplay/interactions/ExecuteScript.js +18 -18
- package/lib/screenplay/interactions/Hover.d.ts +5 -5
- package/lib/screenplay/interactions/Hover.js +5 -5
- package/lib/screenplay/interactions/Navigate.d.ts +8 -8
- package/lib/screenplay/interactions/Navigate.js +8 -8
- package/lib/screenplay/interactions/PageElementInteraction.d.ts +3 -3
- package/lib/screenplay/interactions/PageElementInteraction.js +3 -3
- package/lib/screenplay/interactions/Press.d.ts +10 -10
- package/lib/screenplay/interactions/Press.js +10 -10
- package/lib/screenplay/interactions/RightClick.d.ts +5 -5
- package/lib/screenplay/interactions/RightClick.js +5 -5
- package/lib/screenplay/interactions/Scroll.d.ts +5 -5
- package/lib/screenplay/interactions/Scroll.js +5 -5
- package/lib/screenplay/interactions/Select.d.ts +22 -22
- package/lib/screenplay/interactions/Select.js +22 -22
- package/lib/screenplay/interactions/Switch.d.ts +16 -16
- package/lib/screenplay/interactions/Switch.js +16 -16
- package/lib/screenplay/interactions/TakeScreenshot.d.ts +11 -10
- package/lib/screenplay/interactions/TakeScreenshot.d.ts.map +1 -1
- package/lib/screenplay/interactions/TakeScreenshot.js +11 -10
- package/lib/screenplay/interactions/TakeScreenshot.js.map +1 -1
- package/lib/screenplay/models/BrowserCapabilities.d.ts +1 -1
- package/lib/screenplay/models/BrowsingSession.d.ts +8 -8
- package/lib/screenplay/models/BrowsingSession.js +6 -6
- package/lib/screenplay/models/Cookie.d.ts +10 -10
- package/lib/screenplay/models/Cookie.js +9 -9
- package/lib/screenplay/models/CookieData.d.ts +4 -4
- package/lib/screenplay/models/Key.d.ts +4 -4
- package/lib/screenplay/models/Key.js +4 -4
- package/lib/screenplay/models/Locator.d.ts +8 -8
- package/lib/screenplay/models/Locator.js +8 -8
- package/lib/screenplay/models/Page.d.ts +32 -32
- package/lib/screenplay/models/Page.js +14 -14
- package/lib/screenplay/models/PageElement.d.ts +56 -13
- package/lib/screenplay/models/PageElement.d.ts.map +1 -1
- package/lib/screenplay/models/PageElement.js +36 -6
- package/lib/screenplay/models/PageElement.js.map +1 -1
- package/lib/screenplay/models/PageElements.d.ts +6 -6
- package/lib/screenplay/models/PageElements.js +6 -6
- package/lib/screenplay/models/RootLocator.d.ts +5 -5
- package/lib/screenplay/models/RootLocator.js +5 -5
- package/lib/screenplay/models/SelectOption.d.ts +4 -4
- package/lib/screenplay/models/SelectOption.js +4 -4
- package/lib/screenplay/models/Switchable.d.ts +6 -6
- package/lib/screenplay/models/SwitchableOrigin.d.ts +4 -4
- package/lib/screenplay/models/dialogs/AbsentModalDialog.d.ts +2 -2
- package/lib/screenplay/models/dialogs/AbsentModalDialog.js +2 -2
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.d.ts +3 -3
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.js +3 -3
- package/lib/screenplay/models/dialogs/DismissedModalDialog.d.ts +3 -3
- package/lib/screenplay/models/dialogs/DismissedModalDialog.js +3 -3
- package/lib/screenplay/models/dialogs/ModalDialog.d.ts +12 -9
- package/lib/screenplay/models/dialogs/ModalDialog.d.ts.map +1 -1
- package/lib/screenplay/models/dialogs/ModalDialog.js +10 -7
- package/lib/screenplay/models/dialogs/ModalDialog.js.map +1 -1
- package/lib/screenplay/models/dialogs/ModalDialogHandler.d.ts +5 -5
- package/lib/screenplay/models/dialogs/ModalDialogHandler.js +5 -5
- package/lib/screenplay/models/selectors/By.d.ts +14 -14
- package/lib/screenplay/models/selectors/By.js +14 -14
- package/lib/screenplay/models/selectors/ByCss.d.ts +2 -2
- package/lib/screenplay/models/selectors/ByCss.js +2 -2
- package/lib/screenplay/models/selectors/ByCssContainingText.d.ts +2 -2
- package/lib/screenplay/models/selectors/ByCssContainingText.js +2 -2
- package/lib/screenplay/models/selectors/ByDeepCss.d.ts +2 -2
- package/lib/screenplay/models/selectors/ByDeepCss.js +2 -2
- package/lib/screenplay/models/selectors/ById.d.ts +2 -2
- package/lib/screenplay/models/selectors/ById.js +2 -2
- package/lib/screenplay/models/selectors/ByTagName.d.ts +2 -2
- package/lib/screenplay/models/selectors/ByTagName.js +2 -2
- package/lib/screenplay/models/selectors/ByXPath.d.ts +2 -2
- package/lib/screenplay/models/selectors/ByXPath.js +2 -2
- package/lib/screenplay/models/selectors/Selector.d.ts +1 -1
- package/lib/screenplay/models/selectors/Selector.js +1 -1
- package/lib/screenplay/questions/Attribute.d.ts +13 -13
- package/lib/screenplay/questions/Attribute.js +13 -13
- package/lib/screenplay/questions/ComputedStyle.d.ts +16 -16
- package/lib/screenplay/questions/ComputedStyle.js +16 -16
- package/lib/screenplay/questions/CssClasses.d.ts +13 -13
- package/lib/screenplay/questions/CssClasses.js +13 -13
- package/lib/screenplay/questions/LastScriptExecution.d.ts +7 -7
- package/lib/screenplay/questions/LastScriptExecution.js +7 -7
- package/lib/screenplay/questions/Selected.d.ts +17 -17
- package/lib/screenplay/questions/Selected.js +17 -17
- package/lib/screenplay/questions/Text.d.ts +18 -18
- package/lib/screenplay/questions/Text.js +14 -14
- package/lib/screenplay/questions/Value.d.ts +12 -12
- package/lib/screenplay/questions/Value.js +12 -12
- package/lib/stage/crew/photographer/Photographer.d.ts +18 -17
- package/lib/stage/crew/photographer/Photographer.d.ts.map +1 -1
- package/lib/stage/crew/photographer/Photographer.js +18 -17
- package/lib/stage/crew/photographer/Photographer.js.map +1 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +6 -6
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +6 -6
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +3 -3
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +3 -3
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +3 -3
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +3 -3
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +3 -3
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +3 -3
- package/package.json +5 -5
- package/src/errors/BrowserWindowClosedError.ts +2 -2
- package/src/errors/CookieMissingError.ts +2 -2
- package/src/errors/ModalDialogObstructsScreenshotError.ts +3 -3
- package/src/expectations/isActive.ts +8 -8
- package/src/expectations/isClickable.ts +8 -8
- package/src/expectations/isEnabled.ts +8 -8
- package/src/expectations/isSelected.ts +8 -8
- package/src/expectations/isVisible.ts +8 -8
- package/src/screenplay/abilities/BrowseTheWeb.ts +25 -23
- package/src/screenplay/interactions/Clear.ts +7 -7
- package/src/screenplay/interactions/Click.ts +5 -5
- package/src/screenplay/interactions/DoubleClick.ts +5 -5
- package/src/screenplay/interactions/Enter.ts +5 -5
- package/src/screenplay/interactions/ExecuteScript.ts +19 -19
- package/src/screenplay/interactions/Hover.ts +5 -5
- package/src/screenplay/interactions/Navigate.ts +8 -8
- package/src/screenplay/interactions/PageElementInteraction.ts +3 -3
- package/src/screenplay/interactions/Press.ts +10 -10
- package/src/screenplay/interactions/RightClick.ts +5 -5
- package/src/screenplay/interactions/Scroll.ts +5 -5
- package/src/screenplay/interactions/Select.ts +22 -22
- package/src/screenplay/interactions/Switch.ts +16 -16
- package/src/screenplay/interactions/TakeScreenshot.ts +11 -10
- package/src/screenplay/models/BrowserCapabilities.ts +1 -1
- package/src/screenplay/models/BrowsingSession.ts +8 -8
- package/src/screenplay/models/Cookie.ts +10 -10
- package/src/screenplay/models/CookieData.ts +4 -4
- package/src/screenplay/models/Key.ts +4 -4
- package/src/screenplay/models/Locator.ts +8 -8
- package/src/screenplay/models/Page.ts +32 -32
- package/src/screenplay/models/PageElement.ts +66 -13
- package/src/screenplay/models/PageElements.ts +6 -6
- package/src/screenplay/models/RootLocator.ts +5 -5
- package/src/screenplay/models/SelectOption.ts +4 -4
- package/src/screenplay/models/Switchable.ts +6 -6
- package/src/screenplay/models/SwitchableOrigin.ts +4 -4
- package/src/screenplay/models/dialogs/AbsentModalDialog.ts +2 -2
- package/src/screenplay/models/dialogs/AcceptedModalDialog.ts +3 -3
- package/src/screenplay/models/dialogs/DismissedModalDialog.ts +3 -3
- package/src/screenplay/models/dialogs/ModalDialog.ts +12 -9
- package/src/screenplay/models/dialogs/ModalDialogHandler.ts +5 -5
- package/src/screenplay/models/selectors/By.ts +14 -14
- package/src/screenplay/models/selectors/ByCss.ts +2 -2
- package/src/screenplay/models/selectors/ByCssContainingText.ts +2 -2
- package/src/screenplay/models/selectors/ByDeepCss.ts +2 -2
- package/src/screenplay/models/selectors/ById.ts +2 -2
- package/src/screenplay/models/selectors/ByTagName.ts +2 -2
- package/src/screenplay/models/selectors/ByXPath.ts +2 -2
- package/src/screenplay/models/selectors/Selector.ts +1 -1
- package/src/screenplay/questions/Attribute.ts +13 -13
- package/src/screenplay/questions/ComputedStyle.ts +16 -16
- package/src/screenplay/questions/CssClasses.ts +13 -13
- package/src/screenplay/questions/LastScriptExecution.ts +7 -7
- package/src/screenplay/questions/Selected.ts +17 -17
- package/src/screenplay/questions/Text.ts +18 -18
- package/src/screenplay/questions/Value.ts +12 -12
- package/src/stage/crew/photographer/Photographer.ts +18 -17
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +6 -6
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +3 -3
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +3 -3
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +3 -3
|
@@ -7,14 +7,14 @@ import { RootLocator } from './RootLocator';
|
|
|
7
7
|
import { ByCss, ById, ByTagName, type Selector } from './selectors';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* within the
|
|
10
|
+
* [`Locator`](https://serenity-js.org/api/web/class/Locator/) uses a [`Selector`](https://serenity-js.org/api/web/class/Selector/) to locate a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) or [`PageElement`](https://serenity-js.org/api/web/class/PageElements/)
|
|
11
|
+
* within the [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
12
12
|
*
|
|
13
13
|
* ## Learn more
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
14
|
+
* - [`RootLocator`](https://serenity-js.org/api/web/class/RootLocator/)
|
|
15
|
+
* - [`Page.locate`](https://serenity-js.org/api/web/class/Page/#locate)
|
|
16
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/)
|
|
17
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElements/)
|
|
18
18
|
*
|
|
19
19
|
* @group Models
|
|
20
20
|
*/
|
|
@@ -50,10 +50,10 @@ export abstract class Locator<Native_Element_Type, Native_Selector_Type = any>
|
|
|
50
50
|
abstract locate(child: Locator<Native_Element_Type>): Locator<Native_Element_Type>;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Expresses
|
|
53
|
+
* Expresses [`ByCss`](https://serenity-js.org/api/web/class/ByCss/), [`ById`](https://serenity-js.org/api/web/class/ById/), or [`ByTagName`](https://serenity-js.org/api/web/class/ByTagName/) as a [`ByCss`](https://serenity-js.org/api/web/class/ByCss/) selector.
|
|
54
54
|
*
|
|
55
55
|
* @throws LogicError
|
|
56
|
-
* if the `selector` can't be expressed as
|
|
56
|
+
* if the `selector` can't be expressed as [`ByCss`](https://serenity-js.org/api/web/class/ByCss/)
|
|
57
57
|
*
|
|
58
58
|
* @param selector
|
|
59
59
|
* @protected
|
|
@@ -123,17 +123,17 @@ import type { SwitchableOrigin } from './SwitchableOrigin';
|
|
|
123
123
|
*
|
|
124
124
|
* ## Learn more
|
|
125
125
|
*
|
|
126
|
-
* -
|
|
127
|
-
* -
|
|
128
|
-
* -
|
|
129
|
-
* -
|
|
126
|
+
* - [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/)
|
|
127
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/)
|
|
128
|
+
* - [`Optional`](https://serenity-js.org/api/core/interface/Optional/)
|
|
129
|
+
* - [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
130
130
|
*
|
|
131
131
|
* @group Models
|
|
132
132
|
*/
|
|
133
133
|
export abstract class Page<Native_Element_Type = any> implements Optional, Switchable {
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Creates a
|
|
136
|
+
* Creates a [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) representing the currently active [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
137
137
|
*/
|
|
138
138
|
static current(): QuestionAdapter<Page> {
|
|
139
139
|
return Question.about<Page>('current page', actor => {
|
|
@@ -142,8 +142,8 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Creates a
|
|
146
|
-
* meets the
|
|
145
|
+
* Creates a [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) that resolves to a [`Page`](https://serenity-js.org/api/web/class/Page/) which [`Page.name`](https://serenity-js.org/api/web/class/Page/#name)
|
|
146
|
+
* meets the [expectation](https://serenity-js.org/api/core/class/Expectation/).
|
|
147
147
|
*
|
|
148
148
|
* #### Switching to a page with the desired name
|
|
149
149
|
*
|
|
@@ -172,8 +172,8 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
* Creates a
|
|
176
|
-
* meets the
|
|
175
|
+
* Creates a [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) that resolves to a [`Page`](https://serenity-js.org/api/web/class/Page/) which [`Page.title`](https://serenity-js.org/api/web/class/Page/#title)
|
|
176
|
+
* meets the [expectation](https://serenity-js.org/api/core/class/Expectation/).
|
|
177
177
|
*
|
|
178
178
|
* #### Switching to a page with the desired title
|
|
179
179
|
*
|
|
@@ -202,8 +202,8 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
|
-
* Creates a
|
|
206
|
-
* meets the
|
|
205
|
+
* Creates a [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) that resolves to a [`Page`](https://serenity-js.org/api/web/class/Page/) which [`Page.url`](https://serenity-js.org/api/web/class/Page/#url)
|
|
206
|
+
* meets the [expectation](https://serenity-js.org/api/core/class/Expectation/).
|
|
207
207
|
*
|
|
208
208
|
* #### Switching to a page with the desired URL
|
|
209
209
|
*
|
|
@@ -258,21 +258,21 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
|
-
* Creates a
|
|
261
|
+
* Creates a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) wrapping a native element.
|
|
262
262
|
*
|
|
263
263
|
* @param nativeElement
|
|
264
264
|
*/
|
|
265
265
|
abstract createPageElement(nativeElement: Native_Element_Type): PageElement<Native_Element_Type>;
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
|
-
* Creates a
|
|
268
|
+
* Creates a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/), retrieving an element located by [`Selector`](https://serenity-js.org/api/web/class/Selector/).
|
|
269
269
|
*
|
|
270
270
|
* @param selector
|
|
271
271
|
*/
|
|
272
272
|
abstract locate(selector: Selector): PageElement<Native_Element_Type>;
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
|
-
* Creates
|
|
275
|
+
* Creates [`PageElement`](https://serenity-js.org/api/web/class/PageElements/), retrieving a collection of elements located by [`Selector`](https://serenity-js.org/api/web/class/Selector/).
|
|
276
276
|
*
|
|
277
277
|
* @param selector
|
|
278
278
|
*/
|
|
@@ -296,7 +296,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
296
296
|
|
|
297
297
|
/**
|
|
298
298
|
* Causes the browser to traverse one step backward in the joint session history
|
|
299
|
-
* of the current
|
|
299
|
+
* of the current [`Page`](https://serenity-js.org/api/web/class/Page/) (the current top-level browsing context).
|
|
300
300
|
*
|
|
301
301
|
* This is equivalent to pressing the back button in the browser UI,
|
|
302
302
|
* or calling [`window.history.back`](https://developer.mozilla.org/en-US/docs/Web/API/History/back).
|
|
@@ -305,7 +305,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
305
305
|
|
|
306
306
|
/**
|
|
307
307
|
* Causes the browser to traverse one step forward in the joint session history
|
|
308
|
-
* of the current
|
|
308
|
+
* of the current [`Page`](https://serenity-js.org/api/web/class/Page/) (the current top-level browsing context).
|
|
309
309
|
*
|
|
310
310
|
* This is equivalent to pressing the back button in the browser UI,
|
|
311
311
|
* or calling [`window.history.forward`](https://developer.mozilla.org/en-US/docs/Web/API/History/forward).
|
|
@@ -313,12 +313,12 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
313
313
|
abstract navigateForward(): Promise<void>;
|
|
314
314
|
|
|
315
315
|
/**
|
|
316
|
-
* Causes the browser to reload the
|
|
316
|
+
* Causes the browser to reload the [`Page`](https://serenity-js.org/api/web/class/Page/) in the current top-level browsing context.
|
|
317
317
|
*/
|
|
318
318
|
abstract reload(): Promise<void>;
|
|
319
319
|
|
|
320
320
|
/**
|
|
321
|
-
* Send a sequence of
|
|
321
|
+
* Send a sequence of [`Key`](https://serenity-js.org/api/web/class/Key/) strokes to the active element.
|
|
322
322
|
*
|
|
323
323
|
* @param keys
|
|
324
324
|
* Keys to enter
|
|
@@ -345,7 +345,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
345
345
|
* If the script has a return value (i.e. if the script contains a `return` statement),
|
|
346
346
|
* then the following steps will be taken for resolving this functions return value:
|
|
347
347
|
*
|
|
348
|
-
* - For a
|
|
348
|
+
* - For a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/), the value will resolve to a [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
|
|
349
349
|
* - `null` and `undefined` return values will resolve to `null`
|
|
350
350
|
* - `boolean`, `number`, and `string` values will resolve as is
|
|
351
351
|
* - Functions will resolve to their string representation
|
|
@@ -363,7 +363,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
363
363
|
*
|
|
364
364
|
* #### Learn more
|
|
365
365
|
* - [Selenium WebDriver: JavaScript Executor](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeAsyncScript-java.lang.String-java.lang.Object...-)
|
|
366
|
-
* -
|
|
366
|
+
* - [`Page.lastScriptExecutionResult`](https://serenity-js.org/api/web/class/Page/#lastScriptExecutionResult)
|
|
367
367
|
*
|
|
368
368
|
* @param script
|
|
369
369
|
* @param args
|
|
@@ -385,7 +385,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
385
385
|
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
386
386
|
* to the types previously mentioned.
|
|
387
387
|
*
|
|
388
|
-
* Unlike executing synchronous JavaScript with
|
|
388
|
+
* Unlike executing synchronous JavaScript with [`Page.executeScript`](https://serenity-js.org/api/web/class/Page/#executeScript),
|
|
389
389
|
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
390
390
|
*
|
|
391
391
|
* This callback will always be injected into the executed function as the last argument,
|
|
@@ -394,7 +394,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
394
394
|
* The following steps will be taken for resolving this functions return value against
|
|
395
395
|
* the first argument to the script's callback function:
|
|
396
396
|
*
|
|
397
|
-
* - For a
|
|
397
|
+
* - For a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/), the value will resolve to a [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
|
|
398
398
|
* - `null` and `undefined` return values will resolve to `null`
|
|
399
399
|
* - `boolean`, `number`, and `string` values will resolve as is
|
|
400
400
|
* - Functions will resolve to their string representation
|
|
@@ -423,7 +423,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
423
423
|
*
|
|
424
424
|
* #### Learn more
|
|
425
425
|
* - [Selenium WebDriver: JavaScript Executor](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeAsyncScript-java.lang.String-java.lang.Object...-)
|
|
426
|
-
* -
|
|
426
|
+
* - [`Page.lastScriptExecutionResult`](https://serenity-js.org/api/web/class/Page/#lastScriptExecutionResult)
|
|
427
427
|
*
|
|
428
428
|
* @param script
|
|
429
429
|
* @param args
|
|
@@ -434,15 +434,15 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
434
434
|
): Promise<Result>;
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
|
-
* Returns the last result of calling
|
|
438
|
-
* or
|
|
437
|
+
* Returns the last result of calling [`Page.executeAsyncScript`](https://serenity-js.org/api/web/class/Page/#executeAsyncScript)
|
|
438
|
+
* or [`Page.executeScript`](https://serenity-js.org/api/web/class/Page/#executeScript)
|
|
439
439
|
*/
|
|
440
440
|
abstract lastScriptExecutionResult<R = any>(): R;
|
|
441
441
|
|
|
442
442
|
/**
|
|
443
443
|
* Take a screenshot of the top-level browsing context's viewport.
|
|
444
444
|
*
|
|
445
|
-
* @throws
|
|
445
|
+
* @throws [`BrowserWindowClosedError`](https://serenity-js.org/api/web/class/BrowserWindowClosedError/)
|
|
446
446
|
* When the page you're trying to take the screenshot of has already been closed
|
|
447
447
|
*
|
|
448
448
|
* @return
|
|
@@ -451,15 +451,15 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
451
451
|
abstract takeScreenshot(): Promise<string>;
|
|
452
452
|
|
|
453
453
|
/**
|
|
454
|
-
* Retrieves a cookie identified by `name` and visible to this
|
|
454
|
+
* Retrieves a cookie identified by `name` and visible to this [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
455
455
|
*
|
|
456
456
|
* @param name
|
|
457
457
|
*/
|
|
458
458
|
abstract cookie(name: string): Promise<Cookie>;
|
|
459
459
|
|
|
460
460
|
/**
|
|
461
|
-
* Adds a single cookie with
|
|
462
|
-
* with the active
|
|
461
|
+
* Adds a single cookie with [`CookieData`](https://serenity-js.org/api/web/interface/CookieData/) to the cookie store associated
|
|
462
|
+
* with the active [`Page`](https://serenity-js.org/api/web/class/Page/)'s address.
|
|
463
463
|
*
|
|
464
464
|
* @param cookieData
|
|
465
465
|
*/
|
|
@@ -512,8 +512,8 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
512
512
|
* to the previous context when needed.
|
|
513
513
|
*
|
|
514
514
|
* ## Learn more
|
|
515
|
-
* -
|
|
516
|
-
* -
|
|
515
|
+
* - [`Switch`](https://serenity-js.org/api/web/class/Switch/)
|
|
516
|
+
* - [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
517
517
|
*/
|
|
518
518
|
async switchTo(): Promise<SwitchableOrigin> {
|
|
519
519
|
|
|
@@ -539,7 +539,7 @@ export abstract class Page<Native_Element_Type = any> implements Optional, Switc
|
|
|
539
539
|
abstract closeOthers(): Promise<void>;
|
|
540
540
|
|
|
541
541
|
/**
|
|
542
|
-
* Returns the
|
|
542
|
+
* Returns the [`ModalDialogHandler`](https://serenity-js.org/api/web/class/ModalDialogHandler/) for the current [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
543
543
|
*/
|
|
544
544
|
modalDialog(): ModalDialogHandler {
|
|
545
545
|
return this.modalDialogHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Answerable, MetaQuestionAdapter, Optional } from '@serenity-js/core';
|
|
1
|
+
import type { Answerable, MetaQuestion, MetaQuestionAdapter, Optional , QuestionAdapter} from '@serenity-js/core';
|
|
2
2
|
import { Question, the } from '@serenity-js/core';
|
|
3
3
|
import { ensure, isDefined } from 'tiny-types';
|
|
4
4
|
|
|
@@ -10,13 +10,13 @@ import type { Switchable } from './Switchable';
|
|
|
10
10
|
import type { SwitchableOrigin } from './SwitchableOrigin';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Uses the
|
|
14
|
-
* a single Web element located by
|
|
13
|
+
* Uses the [actor's](https://serenity-js.org/api/core/class/Actor/) [ability](https://serenity-js.org/api/core/class/Ability/) to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) to identify
|
|
14
|
+
* a single Web element located by [`Selector`](https://serenity-js.org/api/web/class/Selector/).
|
|
15
15
|
*
|
|
16
16
|
* ## Learn more
|
|
17
|
-
* - [Page Element Query Language](/handbook/web-testing/page-element-query-language)
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
17
|
+
* - [Page Element Query Language](https://serenity-js.org/handbook/web-testing/page-element-query-language)
|
|
18
|
+
* - [`Optional`](https://serenity-js.org/api/core/interface/Optional/)
|
|
19
|
+
* - [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
20
20
|
*
|
|
21
21
|
* @group Models
|
|
22
22
|
*/
|
|
@@ -51,6 +51,38 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* A static method producing a [`MetaQuestion`](https://serenity-js.org/api/core/interface/MetaQuestion/) that can be used with [`PageElements.eachMappedTo`](https://serenity-js.org/api/web/class/PageElements/#eachMappedTo) method
|
|
56
|
+
* to extract the HTML of each element in a collection.
|
|
57
|
+
*
|
|
58
|
+
* #### Example
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { actorCalled, Log } from '@serenity-js/core'
|
|
62
|
+
* import { Navigate, PageElement, By, Text } from '@serenity-js/web'
|
|
63
|
+
* import { includes } from '@serenity-js/assertions'
|
|
64
|
+
*
|
|
65
|
+
* await actorCalled('Debbie').attemptsTo(
|
|
66
|
+
* Navigate.to('https://serenity-js.org'),
|
|
67
|
+
*
|
|
68
|
+
* Log.the(
|
|
69
|
+
* PageElements.located(By.css('a'))
|
|
70
|
+
* .where(Text, includes('modular'))
|
|
71
|
+
* .eachMappedTo(PageElement.html())
|
|
72
|
+
* ),
|
|
73
|
+
* )
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
static html<NET>(): MetaQuestion<PageElement<NET>, QuestionAdapter<string>> {
|
|
77
|
+
return {
|
|
78
|
+
of: (pageElement: Answerable<PageElement<NET>>) =>
|
|
79
|
+
Question.about(`outer HTML of ${pageElement}`, async actor => {
|
|
80
|
+
const element = await actor.answer(pageElement);
|
|
81
|
+
return element.html();
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
54
86
|
constructor(public readonly locator: Locator<Native_Element_Type>) {
|
|
55
87
|
ensure('native element locator', locator, isDefined());
|
|
56
88
|
}
|
|
@@ -66,7 +98,7 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
66
98
|
|
|
67
99
|
/**
|
|
68
100
|
* Traverses the element and its parents, heading toward the document root,
|
|
69
|
-
* until it finds a parent
|
|
101
|
+
* until it finds a parent [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) that matches its associated CSS selector.
|
|
70
102
|
*
|
|
71
103
|
* #### Example
|
|
72
104
|
*
|
|
@@ -101,9 +133,9 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
101
133
|
* :::info
|
|
102
134
|
* This method relies on [Element: closest() API](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest),
|
|
103
135
|
* and so is only compatible with locating parent elements specified using the following CSS selectors:
|
|
104
|
-
* -
|
|
105
|
-
* -
|
|
106
|
-
* -
|
|
136
|
+
* - [`ByCss`](https://serenity-js.org/api/web/class/ByCss/)
|
|
137
|
+
* - [`ById`](https://serenity-js.org/api/web/class/ById/)
|
|
138
|
+
* - [`ByTagName`](https://serenity-js.org/api/web/class/ByTagName/)
|
|
107
139
|
* :::
|
|
108
140
|
*
|
|
109
141
|
* @param childElement
|
|
@@ -139,6 +171,27 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
139
171
|
abstract text(): Promise<string>;
|
|
140
172
|
abstract value(): Promise<string>;
|
|
141
173
|
|
|
174
|
+
/**
|
|
175
|
+
* An instance method that resolves to the value of the [`outerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) property
|
|
176
|
+
* of the underlying element.
|
|
177
|
+
*
|
|
178
|
+
* #### Example
|
|
179
|
+
*
|
|
180
|
+
* ```typescript
|
|
181
|
+
* import { actorCalled, Log } from '@serenity-js/core'
|
|
182
|
+
* import { Navigate, PageElement, By } from '@serenity-js/web'
|
|
183
|
+
*
|
|
184
|
+
* await actorCalled('Debbie').attemptsTo(
|
|
185
|
+
* Navigate.to('https://serenity-js.org'),
|
|
186
|
+
*
|
|
187
|
+
* Log.the(
|
|
188
|
+
* PageElement.located(By.css('h1')).html()
|
|
189
|
+
* ),
|
|
190
|
+
* )
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
abstract html(): Promise<string>;
|
|
194
|
+
|
|
142
195
|
/**
|
|
143
196
|
* When the element represents an [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe),
|
|
144
197
|
* calling this method switches the current browsing context to the given `iframe` context.
|
|
@@ -151,8 +204,8 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
151
204
|
* to the previous context if needed.
|
|
152
205
|
*
|
|
153
206
|
* #### Learn more
|
|
154
|
-
* -
|
|
155
|
-
* -
|
|
207
|
+
* - [`Switch`](https://serenity-js.org/api/web/class/Switch/)
|
|
208
|
+
* - [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
156
209
|
*/
|
|
157
210
|
abstract switchTo(): Promise<SwitchableOrigin>;
|
|
158
211
|
|
|
@@ -179,7 +232,7 @@ export abstract class PageElement<Native_Element_Type = any> implements Optional
|
|
|
179
232
|
abstract isEnabled(): Promise<boolean>;
|
|
180
233
|
|
|
181
234
|
/**
|
|
182
|
-
* Returns a
|
|
235
|
+
* Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to `true` when the element
|
|
183
236
|
* is present in the [Document Object Model (DOM)](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model),
|
|
184
237
|
* `false` otherwise.
|
|
185
238
|
*/
|
|
@@ -6,15 +6,15 @@ import { PageElementsLocator } from './PageElementsLocator';
|
|
|
6
6
|
import type { Selector } from './selectors';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Uses the
|
|
10
|
-
* a group of Web elements located by
|
|
9
|
+
* Uses the [actor's](https://serenity-js.org/api/core/class/Actor/) [ability](https://serenity-js.org/api/core/class/Ability/) to [`BrowseTheWeb`](https://serenity-js.org/api/web/class/BrowseTheWeb/) to identify
|
|
10
|
+
* a group of Web elements located by [`Selector`](https://serenity-js.org/api/web/class/Selector/).
|
|
11
11
|
*
|
|
12
12
|
* ## Learn more
|
|
13
13
|
*
|
|
14
|
-
* - [Page Element Query Language](/handbook/web-testing/page-element-query-language)
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
14
|
+
* - [Page Element Query Language](https://serenity-js.org/handbook/web-testing/page-element-query-language)
|
|
15
|
+
* - [`Actor`](https://serenity-js.org/api/core/class/Actor/)}
|
|
16
|
+
* - [`List`](https://serenity-js.org/api/core/class/List/)
|
|
17
|
+
* - [`ChainableMetaQuestion`](https://serenity-js.org/api/core/interface/ChainableMetaQuestion/)
|
|
18
18
|
*
|
|
19
19
|
* @group Models
|
|
20
20
|
*/
|
|
@@ -3,14 +3,14 @@ import { inspectedObject } from '@serenity-js/core/lib/io';
|
|
|
3
3
|
import * as util from 'util'; // eslint-disable-line unicorn/import-style
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* [`RootLocator`](https://serenity-js.org/api/web/class/RootLocator/) represents the context in which [`Locator`](https://serenity-js.org/api/web/class/Locator/) looks for [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) or [`PageElement`](https://serenity-js.org/api/web/class/PageElements/).
|
|
7
7
|
* This context is either a parent element, or some representation of the top-level browsing context.
|
|
8
8
|
*
|
|
9
9
|
* ## Learn more
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
10
|
+
* - [`Locator`](https://serenity-js.org/api/web/class/Locator/)
|
|
11
|
+
* - [`Page.locate`](https://serenity-js.org/api/web/class/Page/#locate)
|
|
12
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/)
|
|
13
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElements/)
|
|
14
14
|
*
|
|
15
15
|
* @group Models
|
|
16
16
|
*/
|
|
@@ -6,10 +6,10 @@ import { TinyType } from 'tiny-types';
|
|
|
6
6
|
*
|
|
7
7
|
* ## Learn more
|
|
8
8
|
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
9
|
+
* - [`Select`](https://serenity-js.org/api/web/class/Select/)
|
|
10
|
+
* - [`Selected`](https://serenity-js.org/api/web/class/Selected/)
|
|
11
|
+
* - [`PageElement.selectOptions`](https://serenity-js.org/api/web/class/PageElement/#selectOptions)
|
|
12
|
+
* - [`PageElement.selectedOptions`](https://serenity-js.org/api/web/class/PageElement/#selectedOptions)
|
|
13
13
|
*
|
|
14
14
|
* @group Models
|
|
15
15
|
*/
|
|
@@ -2,14 +2,14 @@ import type { SwitchableOrigin } from './SwitchableOrigin';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Describes a Serenity/JS model object that can be switched _to_ and switched back _from_
|
|
5
|
-
* using the
|
|
5
|
+
* using the [task](https://serenity-js.org/api/core/class/Task/) to [`Switch`](https://serenity-js.org/api/web/class/Switch/).
|
|
6
6
|
*
|
|
7
|
-
* Examples of switchable models include a
|
|
7
|
+
* Examples of switchable models include a [`Page`](https://serenity-js.org/api/web/class/Page/) and [`PageElement`](https://serenity-js.org/api/web/class/PageElement/).
|
|
8
8
|
*
|
|
9
9
|
* ## Learn more
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
10
|
+
* - [`Page`](https://serenity-js.org/api/web/class/Page/)
|
|
11
|
+
* - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/)
|
|
12
|
+
* - [`Switch`](https://serenity-js.org/api/web/class/Switch/)
|
|
13
13
|
*
|
|
14
14
|
* @group Models
|
|
15
15
|
*/
|
|
@@ -17,7 +17,7 @@ export interface Switchable {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Switches the context to the object implementing this interface
|
|
20
|
-
* and returns
|
|
20
|
+
* and returns [`SwitchableOrigin`](https://serenity-js.org/api/web/interface/SwitchableOrigin/) that allows for the context to be switched
|
|
21
21
|
* back when needed.
|
|
22
22
|
*/
|
|
23
23
|
switchTo(): Promise<SwitchableOrigin>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Enables the
|
|
2
|
+
* Enables the [`Task`](https://serenity-js.org/api/core/class/Task/) to [`Switch`](https://serenity-js.org/api/web/class/Switch/) to perform a sequence of activities
|
|
3
3
|
* and switch back to the original context afterwards.
|
|
4
4
|
*
|
|
5
5
|
* ## Learn more
|
|
6
6
|
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - [`Switch`](https://serenity-js.org/api/web/class/Switch/)
|
|
8
|
+
* - [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
9
9
|
*
|
|
10
10
|
* @group Models
|
|
11
11
|
*/
|
|
12
12
|
export interface SwitchableOrigin {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Switches the context back to the original
|
|
15
|
+
* Switches the context back to the original [`Switchable`](https://serenity-js.org/api/web/interface/Switchable/)
|
|
16
16
|
*/
|
|
17
17
|
switchBack(): Promise<void>;
|
|
18
18
|
}
|
|
@@ -4,10 +4,10 @@ import { ModalDialog } from './ModalDialog';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `AbsentModalDialog` is a [null object](https://en.wikipedia.org/wiki/Null_object_pattern)
|
|
7
|
-
* representing a
|
|
7
|
+
* representing a [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/) that hasn't appeared yet.
|
|
8
8
|
*
|
|
9
9
|
* ## Learn more
|
|
10
|
-
* -
|
|
10
|
+
* - [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/)
|
|
11
11
|
*
|
|
12
12
|
* @group Models
|
|
13
13
|
*/
|
|
@@ -3,11 +3,11 @@ import { ensure, isDefined } from 'tiny-types';
|
|
|
3
3
|
import { ModalDialog } from './ModalDialog';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* `AcceptedModalDialog` represents a
|
|
7
|
-
* via
|
|
6
|
+
* `AcceptedModalDialog` represents a [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/) that has been accepted
|
|
7
|
+
* via [`ModalDialog.acceptNext`](https://serenity-js.org/api/web/class/ModalDialog/#acceptNext).
|
|
8
8
|
*
|
|
9
9
|
* ## Learn more
|
|
10
|
-
* -
|
|
10
|
+
* - [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/)
|
|
11
11
|
*
|
|
12
12
|
* @group Models
|
|
13
13
|
*/
|
|
@@ -3,11 +3,11 @@ import { ensure, isDefined } from 'tiny-types';
|
|
|
3
3
|
import { ModalDialog } from './ModalDialog';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* `DismissedModalDialog` represents a
|
|
7
|
-
* via
|
|
6
|
+
* `DismissedModalDialog` represents a [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/) that has been dismissed
|
|
7
|
+
* via [`ModalDialog.dismissNext`](https://serenity-js.org/api/web/class/ModalDialog/#dismissNext).
|
|
8
8
|
*
|
|
9
9
|
* ## Learn more
|
|
10
|
-
* -
|
|
10
|
+
* - [`ModalDialog`](https://serenity-js.org/api/web/class/ModalDialog/)
|
|
11
11
|
*
|
|
12
12
|
* @group Models
|
|
13
13
|
*/
|
|
@@ -14,7 +14,10 @@ import { Page } from '../Page';
|
|
|
14
14
|
* consistent across the various Web integration tools (such as Playwright, Puppeteer,
|
|
15
15
|
* WebdriverIO or Selenium), Serenity/JS works as follows:
|
|
16
16
|
* - Serenity/JS dismisses any modal dialogs by default and stores their message so that it can be asserted on.
|
|
17
|
-
* - This behaviour can be changed by invoking
|
|
17
|
+
* - This behaviour can be changed by invoking [`ModalDialog.acceptNext`](https://serenity-js.org/api/web/class/ModalDialog/#acceptNext),
|
|
18
|
+
* [`ModalDialog.acceptNextWithValue`](https://serenity-js.org/api/web/class/ModalDialog/#acceptNextWithValue),
|
|
19
|
+
* or [`ModalDialog.dismissNext`](https://serenity-js.org/api/web/class/ModalDialog/#dismissNext)
|
|
20
|
+
* before the dialog is triggered, as per the below examples.
|
|
18
21
|
* - Serenity/JS also allows you to `Wait.until(ModalDialog, isPresent())` so that you can synchronise your tests
|
|
19
22
|
* with modal dialogs that appear after a delay.
|
|
20
23
|
*
|
|
@@ -93,7 +96,7 @@ import { Page } from '../Page';
|
|
|
93
96
|
* ```
|
|
94
97
|
*
|
|
95
98
|
* ## Learn more
|
|
96
|
-
* -
|
|
99
|
+
* - [`Optional`](https://serenity-js.org/api/core/interface/Optional/)
|
|
97
100
|
*
|
|
98
101
|
* @group Models
|
|
99
102
|
*/
|
|
@@ -126,7 +129,7 @@ export abstract class ModalDialog implements Optional {
|
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
/**
|
|
129
|
-
* Produces an
|
|
132
|
+
* Produces an [interaction](https://serenity-js.org/api/core/class/Interaction/) that invokes [`ModalDialog.acceptNext`](https://serenity-js.org/api/web/class/ModalDialog/#acceptNext).
|
|
130
133
|
*/
|
|
131
134
|
static acceptNext(): Interaction {
|
|
132
135
|
return Page.current().modalDialog().acceptNext()
|
|
@@ -134,7 +137,7 @@ export abstract class ModalDialog implements Optional {
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
/**
|
|
137
|
-
* Produces an
|
|
140
|
+
* Produces an [interaction](https://serenity-js.org/api/core/class/Interaction/) that invokes [`ModalDialog.acceptNextWithValue`](https://serenity-js.org/api/web/class/ModalDialog/#acceptNextWithValue).
|
|
138
141
|
*
|
|
139
142
|
* @param value
|
|
140
143
|
*/
|
|
@@ -144,7 +147,7 @@ export abstract class ModalDialog implements Optional {
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
/**
|
|
147
|
-
* Produces an
|
|
150
|
+
* Produces an [interaction](https://serenity-js.org/api/core/class/Interaction/) that invokes [`ModalDialog.dismissNext`](https://serenity-js.org/api/web/class/ModalDialog/#dismissNext).
|
|
148
151
|
*/
|
|
149
152
|
static dismissNext(): Interaction {
|
|
150
153
|
return Page.current().modalDialog().dismissNext()
|
|
@@ -152,7 +155,7 @@ export abstract class ModalDialog implements Optional {
|
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
/**
|
|
155
|
-
*
|
|
158
|
+
* [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) that resolves to [`ModalDialog.message`](https://serenity-js.org/api/web/class/ModalDialog/#message) for the current [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
156
159
|
*/
|
|
157
160
|
static lastDialogMessage(): QuestionAdapter<string> {
|
|
158
161
|
return Page.current().modalDialog().last().message()
|
|
@@ -160,7 +163,7 @@ export abstract class ModalDialog implements Optional {
|
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
/**
|
|
163
|
-
*
|
|
166
|
+
* [`QuestionAdapter`](https://serenity-js.org/api/core/#QuestionAdapter) that resolves to [`ModalDialog.state`](https://serenity-js.org/api/web/class/ModalDialog/#state) for the current [`Page`](https://serenity-js.org/api/web/class/Page/).
|
|
164
167
|
*/
|
|
165
168
|
static lastDialogState(): QuestionAdapter<string> {
|
|
166
169
|
return Page.current().modalDialog().last().state()
|
|
@@ -169,12 +172,12 @@ export abstract class ModalDialog implements Optional {
|
|
|
169
172
|
|
|
170
173
|
/**
|
|
171
174
|
* Returns the message of the last modal dialog handled,
|
|
172
|
-
* or rejects the promise with a
|
|
175
|
+
* or rejects the promise with a [`LogicError`](https://serenity-js.org/api/core/class/LogicError/)
|
|
173
176
|
* when no modal dialogs have been observed yet.
|
|
174
177
|
*
|
|
175
178
|
* @returns
|
|
176
179
|
* Message of the last handled dialog, or a `Promise`
|
|
177
|
-
* rejected with a
|
|
180
|
+
* rejected with a [`LogicError`](https://serenity-js.org/api/core/class/LogicError/)
|
|
178
181
|
* when no dialog has been handled yet.
|
|
179
182
|
*/
|
|
180
183
|
abstract message(): Promise<string>;
|