@serenity-js/web 3.0.0-rc.0
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 +50 -0
- package/LICENSE.md +201 -0
- package/NOTICE.md +1 -0
- package/README.md +21 -0
- package/lib/errors/CookieMissingError.d.ts +4 -0
- package/lib/errors/CookieMissingError.js +11 -0
- package/lib/errors/CookieMissingError.js.map +1 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +14 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/expectations/ElementExpectation.d.ts +11 -0
- package/lib/expectations/ElementExpectation.js +27 -0
- package/lib/expectations/ElementExpectation.js.map +1 -0
- package/lib/expectations/index.d.ts +6 -0
- package/lib/expectations/index.js +19 -0
- package/lib/expectations/index.js.map +1 -0
- package/lib/expectations/isActive.d.ts +15 -0
- package/lib/expectations/isActive.js +22 -0
- package/lib/expectations/isActive.js.map +1 -0
- package/lib/expectations/isClickable.d.ts +20 -0
- package/lib/expectations/isClickable.js +30 -0
- package/lib/expectations/isClickable.js.map +1 -0
- package/lib/expectations/isEnabled.d.ts +14 -0
- package/lib/expectations/isEnabled.js +20 -0
- package/lib/expectations/isEnabled.js.map +1 -0
- package/lib/expectations/isPresent.d.ts +15 -0
- package/lib/expectations/isPresent.js +22 -0
- package/lib/expectations/isPresent.js.map +1 -0
- package/lib/expectations/isSelected.d.ts +14 -0
- package/lib/expectations/isSelected.js +23 -0
- package/lib/expectations/isSelected.js.map +1 -0
- package/lib/expectations/isVisible.d.ts +14 -0
- package/lib/expectations/isVisible.js +26 -0
- package/lib/expectations/isVisible.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/input/Key.d.ts +73 -0
- package/lib/input/Key.js +84 -0
- package/lib/input/Key.js.map +1 -0
- package/lib/input/index.d.ts +1 -0
- package/lib/input/index.js +14 -0
- package/lib/input/index.js.map +1 -0
- package/lib/screenplay/abilities/BrowseTheWeb.d.ts +58 -0
- package/lib/screenplay/abilities/BrowseTheWeb.js +19 -0
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +1 -0
- package/lib/screenplay/abilities/BrowserCapabilities.d.ts +5 -0
- package/lib/screenplay/abilities/BrowserCapabilities.js +3 -0
- package/lib/screenplay/abilities/BrowserCapabilities.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +2 -0
- package/lib/screenplay/abilities/index.js +15 -0
- package/lib/screenplay/abilities/index.js.map +1 -0
- package/lib/screenplay/index.d.ts +4 -0
- package/lib/screenplay/index.js +17 -0
- package/lib/screenplay/index.js.map +1 -0
- package/lib/screenplay/interactions/Clear.d.ts +79 -0
- package/lib/screenplay/interactions/Clear.js +97 -0
- package/lib/screenplay/interactions/Clear.js.map +1 -0
- package/lib/screenplay/interactions/Click.d.ts +73 -0
- package/lib/screenplay/interactions/Click.js +85 -0
- package/lib/screenplay/interactions/Click.js.map +1 -0
- package/lib/screenplay/interactions/DoubleClick.d.ts +90 -0
- package/lib/screenplay/interactions/DoubleClick.js +101 -0
- package/lib/screenplay/interactions/DoubleClick.js.map +1 -0
- package/lib/screenplay/interactions/Enter.d.ts +73 -0
- package/lib/screenplay/interactions/Enter.js +86 -0
- package/lib/screenplay/interactions/Enter.js.map +1 -0
- package/lib/screenplay/interactions/EnterBuilder.d.ts +25 -0
- package/lib/screenplay/interactions/EnterBuilder.js +3 -0
- package/lib/screenplay/interactions/EnterBuilder.js.map +1 -0
- package/lib/screenplay/interactions/ExecuteScript.d.ts +206 -0
- package/lib/screenplay/interactions/ExecuteScript.js +312 -0
- package/lib/screenplay/interactions/ExecuteScript.js.map +1 -0
- package/lib/screenplay/interactions/Hover.d.ts +78 -0
- package/lib/screenplay/interactions/Hover.js +89 -0
- package/lib/screenplay/interactions/Hover.js.map +1 -0
- package/lib/screenplay/interactions/Navigate.d.ts +142 -0
- package/lib/screenplay/interactions/Navigate.js +198 -0
- package/lib/screenplay/interactions/Navigate.js.map +1 -0
- package/lib/screenplay/interactions/PageElementInteraction.d.ts +39 -0
- package/lib/screenplay/interactions/PageElementInteraction.js +54 -0
- package/lib/screenplay/interactions/PageElementInteraction.js.map +1 -0
- package/lib/screenplay/interactions/Press.d.ts +84 -0
- package/lib/screenplay/interactions/Press.js +171 -0
- package/lib/screenplay/interactions/Press.js.map +1 -0
- package/lib/screenplay/interactions/PressBuilder.d.ts +26 -0
- package/lib/screenplay/interactions/PressBuilder.js +3 -0
- package/lib/screenplay/interactions/PressBuilder.js.map +1 -0
- package/lib/screenplay/interactions/RightClick.d.ts +89 -0
- package/lib/screenplay/interactions/RightClick.js +100 -0
- package/lib/screenplay/interactions/RightClick.js.map +1 -0
- package/lib/screenplay/interactions/Scroll.d.ts +83 -0
- package/lib/screenplay/interactions/Scroll.js +97 -0
- package/lib/screenplay/interactions/Scroll.js.map +1 -0
- package/lib/screenplay/interactions/Select.d.ts +212 -0
- package/lib/screenplay/interactions/Select.js +291 -0
- package/lib/screenplay/interactions/Select.js.map +1 -0
- package/lib/screenplay/interactions/SelectBuilder.d.ts +33 -0
- package/lib/screenplay/interactions/SelectBuilder.js +3 -0
- package/lib/screenplay/interactions/SelectBuilder.js.map +1 -0
- package/lib/screenplay/interactions/Switch.d.ts +150 -0
- package/lib/screenplay/interactions/Switch.js +209 -0
- package/lib/screenplay/interactions/Switch.js.map +1 -0
- package/lib/screenplay/interactions/TakeScreenshot.d.ts +67 -0
- package/lib/screenplay/interactions/TakeScreenshot.js +86 -0
- package/lib/screenplay/interactions/TakeScreenshot.js.map +1 -0
- package/lib/screenplay/interactions/Wait.d.ts +143 -0
- package/lib/screenplay/interactions/Wait.js +242 -0
- package/lib/screenplay/interactions/Wait.js.map +1 -0
- package/lib/screenplay/interactions/WaitBuilder.d.ts +32 -0
- package/lib/screenplay/interactions/WaitBuilder.js +3 -0
- package/lib/screenplay/interactions/WaitBuilder.js.map +1 -0
- package/lib/screenplay/interactions/index.d.ts +16 -0
- package/lib/screenplay/interactions/index.js +29 -0
- package/lib/screenplay/interactions/index.js.map +1 -0
- package/lib/screenplay/models/Cookie.d.ts +117 -0
- package/lib/screenplay/models/Cookie.js +176 -0
- package/lib/screenplay/models/Cookie.js.map +1 -0
- package/lib/screenplay/models/CookieData.d.ts +89 -0
- package/lib/screenplay/models/CookieData.js +3 -0
- package/lib/screenplay/models/CookieData.js.map +1 -0
- package/lib/screenplay/models/ModalDialog.d.ts +9 -0
- package/lib/screenplay/models/ModalDialog.js +14 -0
- package/lib/screenplay/models/ModalDialog.js.map +1 -0
- package/lib/screenplay/models/Page.d.ts +83 -0
- package/lib/screenplay/models/Page.js +52 -0
- package/lib/screenplay/models/Page.js.map +1 -0
- package/lib/screenplay/models/PageElement.d.ts +30 -0
- package/lib/screenplay/models/PageElement.js +62 -0
- package/lib/screenplay/models/PageElement.js.map +1 -0
- package/lib/screenplay/models/PageElements.d.ts +20 -0
- package/lib/screenplay/models/PageElements.js +49 -0
- package/lib/screenplay/models/PageElements.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +6 -0
- package/lib/screenplay/models/index.js +19 -0
- package/lib/screenplay/models/index.js.map +1 -0
- package/lib/screenplay/questions/Attribute.d.ts +83 -0
- package/lib/screenplay/questions/Attribute.js +103 -0
- package/lib/screenplay/questions/Attribute.js.map +1 -0
- package/lib/screenplay/questions/CssClasses.d.ts +93 -0
- package/lib/screenplay/questions/CssClasses.js +113 -0
- package/lib/screenplay/questions/CssClasses.js.map +1 -0
- package/lib/screenplay/questions/ElementQuestion.d.ts +34 -0
- package/lib/screenplay/questions/ElementQuestion.js +53 -0
- package/lib/screenplay/questions/ElementQuestion.js.map +1 -0
- package/lib/screenplay/questions/LastScriptExecution.d.ts +14 -0
- package/lib/screenplay/questions/LastScriptExecution.js +22 -0
- package/lib/screenplay/questions/LastScriptExecution.js.map +1 -0
- package/lib/screenplay/questions/Selected.d.ts +185 -0
- package/lib/screenplay/questions/Selected.js +210 -0
- package/lib/screenplay/questions/Selected.js.map +1 -0
- package/lib/screenplay/questions/Text.d.ts +99 -0
- package/lib/screenplay/questions/Text.js +131 -0
- package/lib/screenplay/questions/Text.js.map +1 -0
- package/lib/screenplay/questions/Value.d.ts +64 -0
- package/lib/screenplay/questions/Value.js +78 -0
- package/lib/screenplay/questions/Value.js.map +1 -0
- package/lib/screenplay/questions/index.d.ts +6 -0
- package/lib/screenplay/questions/index.js +19 -0
- package/lib/screenplay/questions/index.js.map +1 -0
- package/lib/stage/crew/index.d.ts +1 -0
- package/lib/stage/crew/index.js +14 -0
- package/lib/stage/crew/index.js.map +1 -0
- package/lib/stage/crew/photographer/Photographer.d.ts +83 -0
- package/lib/stage/crew/photographer/Photographer.js +102 -0
- package/lib/stage/crew/photographer/Photographer.js.map +1 -0
- package/lib/stage/crew/photographer/index.d.ts +2 -0
- package/lib/stage/crew/photographer/index.js +15 -0
- package/lib/stage/crew/photographer/index.js.map +1 -0
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +28 -0
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +81 -0
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +18 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +30 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +17 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +28 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +1 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +19 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +28 -0
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +1 -0
- package/lib/stage/crew/photographer/strategies/index.d.ts +4 -0
- package/lib/stage/crew/photographer/strategies/index.js +17 -0
- package/lib/stage/crew/photographer/strategies/index.js.map +1 -0
- package/lib/stage/index.d.ts +1 -0
- package/lib/stage/index.js +14 -0
- package/lib/stage/index.js.map +1 -0
- package/package.json +85 -0
- package/src/errors/CookieMissingError.ts +7 -0
- package/src/errors/index.ts +1 -0
- package/src/expectations/ElementExpectation.ts +32 -0
- package/src/expectations/index.ts +6 -0
- package/src/expectations/isActive.ts +22 -0
- package/src/expectations/isClickable.ts +32 -0
- package/src/expectations/isEnabled.ts +19 -0
- package/src/expectations/isPresent.ts +21 -0
- package/src/expectations/isSelected.ts +24 -0
- package/src/expectations/isVisible.ts +28 -0
- package/src/index.ts +5 -0
- package/src/input/Key.ts +83 -0
- package/src/input/index.ts +1 -0
- package/src/screenplay/abilities/BrowseTheWeb.ts +89 -0
- package/src/screenplay/abilities/BrowserCapabilities.ts +5 -0
- package/src/screenplay/abilities/index.ts +2 -0
- package/src/screenplay/index.ts +4 -0
- package/src/screenplay/interactions/Clear.ts +102 -0
- package/src/screenplay/interactions/Click.ts +86 -0
- package/src/screenplay/interactions/DoubleClick.ts +102 -0
- package/src/screenplay/interactions/Enter.ts +92 -0
- package/src/screenplay/interactions/EnterBuilder.ts +28 -0
- package/src/screenplay/interactions/ExecuteScript.ts +345 -0
- package/src/screenplay/interactions/Hover.ts +90 -0
- package/src/screenplay/interactions/Navigate.ts +209 -0
- package/src/screenplay/interactions/PageElementInteraction.ts +59 -0
- package/src/screenplay/interactions/Press.ts +194 -0
- package/src/screenplay/interactions/PressBuilder.ts +29 -0
- package/src/screenplay/interactions/RightClick.ts +100 -0
- package/src/screenplay/interactions/Scroll.ts +99 -0
- package/src/screenplay/interactions/Select.ts +317 -0
- package/src/screenplay/interactions/SelectBuilder.ts +36 -0
- package/src/screenplay/interactions/Switch.ts +225 -0
- package/src/screenplay/interactions/TakeScreenshot.ts +89 -0
- package/src/screenplay/interactions/Wait.ts +264 -0
- package/src/screenplay/interactions/WaitBuilder.ts +34 -0
- package/src/screenplay/interactions/index.ts +16 -0
- package/src/screenplay/models/Cookie.ts +219 -0
- package/src/screenplay/models/CookieData.ts +97 -0
- package/src/screenplay/models/ModalDialog.ts +19 -0
- package/src/screenplay/models/Page.ts +147 -0
- package/src/screenplay/models/PageElement.ts +95 -0
- package/src/screenplay/models/PageElements.ts +70 -0
- package/src/screenplay/models/index.ts +6 -0
- package/src/screenplay/questions/Attribute.ts +112 -0
- package/src/screenplay/questions/CssClasses.ts +118 -0
- package/src/screenplay/questions/ElementQuestion.ts +60 -0
- package/src/screenplay/questions/LastScriptExecution.ts +21 -0
- package/src/screenplay/questions/Selected.ts +212 -0
- package/src/screenplay/questions/Text.ts +153 -0
- package/src/screenplay/questions/Value.ts +82 -0
- package/src/screenplay/questions/index.ts +6 -0
- package/src/stage/crew/index.ts +1 -0
- package/src/stage/crew/photographer/Photographer.ts +108 -0
- package/src/stage/crew/photographer/index.ts +2 -0
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +116 -0
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +28 -0
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +26 -0
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +26 -0
- package/src/stage/crew/photographer/strategies/index.ts +4 -0
- package/src/stage/index.ts +1 -0
- package/tsconfig.eslint.json +10 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Timestamp } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* A data structure describing a {@link Cookie} to be set or that's been read.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface CookieData {
|
|
9
|
+
/**
|
|
10
|
+
* @desc
|
|
11
|
+
* The name of the cookie.
|
|
12
|
+
*
|
|
13
|
+
* @type {string}
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* @desc
|
|
19
|
+
* The value of the cookie.
|
|
20
|
+
*
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
value: string;
|
|
25
|
+
/**
|
|
26
|
+
* @desc
|
|
27
|
+
* The domain the cookie is visible to.
|
|
28
|
+
* Defaults to the current browsing context's document's URL when setting a cookie.
|
|
29
|
+
*
|
|
30
|
+
* Optional.
|
|
31
|
+
*
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
domain?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @desc
|
|
38
|
+
* The cookie path. Defaults to "/" when adding a cookie.
|
|
39
|
+
*
|
|
40
|
+
* Optional.
|
|
41
|
+
*
|
|
42
|
+
* @type {string}
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
path?: string;
|
|
46
|
+
/**
|
|
47
|
+
* @desc
|
|
48
|
+
* The {@link @serenity-js/core/lib/model~Timestamp} of when the cookie expires.
|
|
49
|
+
*
|
|
50
|
+
* Optional.
|
|
51
|
+
*
|
|
52
|
+
* @type {@serenity-js/core/lib/model~Timestamp}
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
expiry?: Timestamp;
|
|
56
|
+
/**
|
|
57
|
+
* @desc
|
|
58
|
+
* Whether the cookie is an HTTP-only cookie. Defaults to false when adding a new cookie.
|
|
59
|
+
*
|
|
60
|
+
* Optional.
|
|
61
|
+
*
|
|
62
|
+
* @type {boolean}
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
httpOnly?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @desc
|
|
68
|
+
* Whether the cookie is a secure cookie. Defaults to false when adding a new cookie.
|
|
69
|
+
*
|
|
70
|
+
* Optional.
|
|
71
|
+
*
|
|
72
|
+
* @type {boolean}
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
secure?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @desc
|
|
78
|
+
* Whether the cookie applies to a SameSite policy.
|
|
79
|
+
* Defaults to "None" if omitted when adding a cookie.
|
|
80
|
+
*
|
|
81
|
+
* Can be set to either "Lax" or "Strict".
|
|
82
|
+
*
|
|
83
|
+
* Optional.
|
|
84
|
+
*
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
sameSite?: 'Lax' | 'Strict' | 'None';
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CookieData.js","sourceRoot":"","sources":["../../../src/screenplay/models/CookieData.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Adapter, Question } from '@serenity-js/core';
|
|
2
|
+
export declare abstract class ModalDialog {
|
|
3
|
+
static window(): Question<Promise<ModalDialog>> & Adapter<ModalDialog>;
|
|
4
|
+
abstract accept(): Promise<void>;
|
|
5
|
+
abstract dismiss(): Promise<void>;
|
|
6
|
+
abstract text(): Promise<string>;
|
|
7
|
+
abstract enterValue(value: string | number | Array<string | number>): Promise<void>;
|
|
8
|
+
abstract isPresent(): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModalDialog = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
class ModalDialog {
|
|
7
|
+
static window() {
|
|
8
|
+
return core_1.Question.about('modal dialog', actor => {
|
|
9
|
+
return abilities_1.BrowseTheWeb.as(actor).modalDialog();
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ModalDialog = ModalDialog;
|
|
14
|
+
//# sourceMappingURL=ModalDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalDialog.js","sourceRoot":"","sources":["../../../src/screenplay/models/ModalDialog.ts"],"names":[],"mappings":";;;AAAA,4CAAsD;AAEtD,4CAA4C;AAE5C,MAAsB,WAAW;IAC7B,MAAM,CAAC,MAAM;QACT,OAAO,eAAQ,CAAC,KAAK,CAAuB,cAAc,EAAE,KAAK,CAAC,EAAE;YAChE,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;CASJ;AAdD,kCAcC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Adapter, Expectation, Question } from '@serenity-js/core';
|
|
3
|
+
import { URL } from 'url';
|
|
4
|
+
export declare abstract class Page {
|
|
5
|
+
protected readonly handle: string;
|
|
6
|
+
static current(): Question<Promise<Page>> & Adapter<Page>;
|
|
7
|
+
static whichName(expectation: Expectation<any, string>): Question<Promise<Page>> & Adapter<Page>;
|
|
8
|
+
static whichTitle(expectation: Expectation<any, string>): Question<Promise<Page>> & Adapter<Page>;
|
|
9
|
+
static whichUrl(expectation: Expectation<any, string>): Question<Promise<Page>> & Adapter<Page>;
|
|
10
|
+
private static findMatchingPage;
|
|
11
|
+
constructor(handle: string);
|
|
12
|
+
/**
|
|
13
|
+
* @desc
|
|
14
|
+
* Retrieves the document title of the current top-level browsing context, equivalent to calling `document.title`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
17
|
+
*
|
|
18
|
+
* @returns {Promise<string>}
|
|
19
|
+
*/
|
|
20
|
+
abstract title(): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* @desc
|
|
23
|
+
* Retrieves the URL of the current top-level browsing context.
|
|
24
|
+
*
|
|
25
|
+
* @returns {Promise<URL>}
|
|
26
|
+
*/
|
|
27
|
+
abstract url(): Promise<URL>;
|
|
28
|
+
/**
|
|
29
|
+
* @desc
|
|
30
|
+
* Retrieves the name of the current top-level browsing context.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<string>}
|
|
33
|
+
*/
|
|
34
|
+
abstract name(): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* @desc
|
|
37
|
+
* Checks if a given window / tab / page is open and can be switched to.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Promise<string>}
|
|
40
|
+
*/
|
|
41
|
+
abstract isPresent(): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* @desc
|
|
44
|
+
* Returns the actual viewport size available for the given page,
|
|
45
|
+
* excluding any scrollbars.
|
|
46
|
+
*
|
|
47
|
+
* @returns {Promise<{ width: number, height: number }>}
|
|
48
|
+
*/
|
|
49
|
+
abstract viewportSize(): Promise<{
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param size
|
|
56
|
+
*/
|
|
57
|
+
abstract setViewportSize(size: {
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* @desc
|
|
63
|
+
* Switches the current top-level browsing context to the given page
|
|
64
|
+
*
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
abstract switchTo(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* @desc
|
|
70
|
+
* Closes the given page.
|
|
71
|
+
*
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
abstract close(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* @desc
|
|
77
|
+
* Closes any open pages, except for this one.
|
|
78
|
+
*
|
|
79
|
+
* @returns {Promise<void>}
|
|
80
|
+
*/
|
|
81
|
+
abstract closeOthers(): Promise<void>;
|
|
82
|
+
toString(): string;
|
|
83
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Page = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
class Page {
|
|
7
|
+
constructor(handle) {
|
|
8
|
+
this.handle = handle;
|
|
9
|
+
}
|
|
10
|
+
static current() {
|
|
11
|
+
return core_1.Question.about('current page', actor => {
|
|
12
|
+
return abilities_1.BrowseTheWeb.as(actor).currentPage();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
static whichName(expectation) {
|
|
16
|
+
return core_1.Question.about(`page which name does ${expectation}`, async (actor) => {
|
|
17
|
+
const pages = await abilities_1.BrowseTheWeb.as(actor).allPages();
|
|
18
|
+
const matcher = await actor.answer(expectation);
|
|
19
|
+
return Page.findMatchingPage(`name does ${expectation}`, pages, page => page.name().then(matcher));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
static whichTitle(expectation) {
|
|
23
|
+
return core_1.Question.about(`page which title does ${expectation}`, async (actor) => {
|
|
24
|
+
const pages = await abilities_1.BrowseTheWeb.as(actor).allPages();
|
|
25
|
+
const matcher = await actor.answer(expectation);
|
|
26
|
+
return Page.findMatchingPage(`title does ${expectation}`, pages, page => page.title().then(title => {
|
|
27
|
+
return matcher(title);
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
static whichUrl(expectation) {
|
|
32
|
+
return core_1.Question.about(`page which URL does ${expectation}`, async (actor) => {
|
|
33
|
+
const pages = await abilities_1.BrowseTheWeb.as(actor).allPages();
|
|
34
|
+
const matcher = await actor.answer(expectation);
|
|
35
|
+
return Page.findMatchingPage(`url does ${expectation}`, pages, page => page.url().then(url => matcher(url.toString())));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
static async findMatchingPage(expectationDescription, pages, matcher) {
|
|
39
|
+
for (const page of pages) {
|
|
40
|
+
const outcome = await matcher(page);
|
|
41
|
+
if (outcome instanceof core_1.ExpectationMet) {
|
|
42
|
+
return page;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw new core_1.LogicError(`Couldn't find a page which ${expectationDescription}`);
|
|
46
|
+
}
|
|
47
|
+
toString() {
|
|
48
|
+
return `page (handle=${this.handle})`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Page = Page;
|
|
52
|
+
//# sourceMappingURL=Page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../../../src/screenplay/models/Page.ts"],"names":[],"mappings":";;;AAAA,4CAAmH;AAGnH,4CAA4C;AAE5C,MAAsB,IAAI;IA4DtB,YACuB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAErC,CAAC;IA9DD,MAAM,CAAC,OAAO;QACV,OAAO,eAAQ,CAAC,KAAK,CAAgB,cAAc,EAAE,KAAK,CAAC,EAAE;YACzD,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,WAAqC;QAClD,OAAO,eAAQ,CAAC,KAAK,CAAC,wBAAyB,WAAY,EAAE,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACzE,MAAM,KAAK,GAAO,MAAM,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC1D,MAAM,OAAO,GAAK,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAElD,OAAO,IAAI,CAAC,gBAAgB,CACxB,aAAc,WAAY,EAAE,EAC5B,KAAK,EACL,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CACpC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,WAAqC;QACnD,OAAO,eAAQ,CAAC,KAAK,CAAC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YAErC,IAAI,OAAO,YAAY,qBAAc,EAAE;gBACnC,OAAO,IAAI,CAAC;aACf;SACJ;QAED,MAAM,IAAI,iBAAU,CAAC,8BAA+B,sBAAuB,EAAE,CAAC,CAAC;IACnF,CAAC;IAgFD,QAAQ;QACJ,OAAO,gBAAiB,IAAI,CAAC,MAAO,GAAG,CAAC;IAC5C,CAAC;CACJ;AA7ID,oBA6IC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Adapter, Answerable, Question } from '@serenity-js/core';
|
|
2
|
+
export declare abstract class PageElement<NativeElementContext = any, NativeElement = any> {
|
|
3
|
+
protected readonly context: () => Promise<NativeElementContext> | NativeElementContext;
|
|
4
|
+
protected readonly locator: (root: NativeElementContext) => Promise<NativeElement> | NativeElement;
|
|
5
|
+
static of(childElement: Answerable<PageElement>, parentElement: Answerable<PageElement>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
6
|
+
static locatedByCss(selector: Answerable<string>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
7
|
+
static locatedByCssContainingText(selector: Answerable<string>, text: Answerable<string>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
8
|
+
static locatedById(selector: Answerable<string>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
9
|
+
static locatedByTagName(tagName: Answerable<string>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
10
|
+
static locatedByXPath(selector: Answerable<string>): Question<Promise<PageElement>> & Adapter<PageElement>;
|
|
11
|
+
constructor(context: () => Promise<NativeElementContext> | NativeElementContext, locator: (root: NativeElementContext) => Promise<NativeElement> | NativeElement);
|
|
12
|
+
abstract of(parent: PageElement): PageElement;
|
|
13
|
+
nativeElement(): Promise<NativeElement>;
|
|
14
|
+
abstract enterValue(value: string | number | Array<string | number>): Promise<void>;
|
|
15
|
+
abstract clearValue(): Promise<void>;
|
|
16
|
+
abstract click(): Promise<void>;
|
|
17
|
+
abstract doubleClick(): Promise<void>;
|
|
18
|
+
abstract scrollIntoView(): Promise<void>;
|
|
19
|
+
abstract hoverOver(): Promise<void>;
|
|
20
|
+
abstract rightClick(): Promise<void>;
|
|
21
|
+
abstract attribute(name: string): Promise<string>;
|
|
22
|
+
abstract text(): Promise<string>;
|
|
23
|
+
abstract value(): Promise<string>;
|
|
24
|
+
abstract isActive(): Promise<boolean>;
|
|
25
|
+
abstract isClickable(): Promise<boolean>;
|
|
26
|
+
abstract isDisplayed(): Promise<boolean>;
|
|
27
|
+
abstract isEnabled(): Promise<boolean>;
|
|
28
|
+
abstract isPresent(): Promise<boolean>;
|
|
29
|
+
abstract isSelected(): Promise<boolean>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageElement = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
const d = (0, core_1.format)({ markQuestions: false });
|
|
7
|
+
const f = (0, core_1.format)({ markQuestions: true });
|
|
8
|
+
class PageElement {
|
|
9
|
+
constructor(context, locator) {
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.locator = locator;
|
|
12
|
+
}
|
|
13
|
+
static of(childElement, parentElement) {
|
|
14
|
+
return core_1.Question.about(d `${childElement} of ${parentElement})`, async (actor) => {
|
|
15
|
+
const child = await actor.answer(childElement);
|
|
16
|
+
const parent = await actor.answer(parentElement);
|
|
17
|
+
return child.of(parent);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
static locatedByCss(selector) {
|
|
21
|
+
return core_1.Question.about(f `page element located by css (${selector})`, async (actor) => {
|
|
22
|
+
const cssSelector = await actor.answer(selector);
|
|
23
|
+
return abilities_1.BrowseTheWeb.as(actor).findByCss(cssSelector);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static locatedByCssContainingText(selector, text) {
|
|
27
|
+
return core_1.Question.about(f `page element located by css (${selector}) containing text ${text}`, async (actor) => {
|
|
28
|
+
const cssSelector = await actor.answer(selector);
|
|
29
|
+
const desiredText = await actor.answer(text);
|
|
30
|
+
return abilities_1.BrowseTheWeb.as(actor).findByCssContainingText(cssSelector, desiredText);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static locatedById(selector) {
|
|
34
|
+
return core_1.Question.about(f `page element located by id (${selector})`, async (actor) => {
|
|
35
|
+
const idSelector = await actor.answer(selector);
|
|
36
|
+
return abilities_1.BrowseTheWeb.as(actor).findById(idSelector);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
static locatedByTagName(tagName) {
|
|
40
|
+
return core_1.Question.about(f `page element located by tag name (${tagName})`, async (actor) => {
|
|
41
|
+
const tagNameSelector = await actor.answer(tagName);
|
|
42
|
+
return abilities_1.BrowseTheWeb.as(actor).findByTagName(tagNameSelector);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
static locatedByXPath(selector) {
|
|
46
|
+
return core_1.Question.about(f `page element located by xpath (${selector})`, async (actor) => {
|
|
47
|
+
const xpathSelector = await actor.answer(selector);
|
|
48
|
+
return abilities_1.BrowseTheWeb.as(actor).findByXPath(xpathSelector);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async nativeElement() {
|
|
52
|
+
try {
|
|
53
|
+
const context = await this.context();
|
|
54
|
+
return this.locator(context);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new core_1.LogicError(`Couldn't find element`, error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.PageElement = PageElement;
|
|
62
|
+
//# sourceMappingURL=PageElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageElement.js","sourceRoot":"","sources":["../../../src/screenplay/models/PageElement.ts"],"names":[],"mappings":";;;AAAA,4CAAsF;AAEtF,4CAA4C;AAE5C,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,EAAE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C;IACP,CAAC;IAUD,KAAK,CAAC,aAAa;QACf,IAAI;YACA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SAChC;QACD,OAAO,KAAK,EAAE;YACV,MAAM,IAAI,iBAAU,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;SACxD;IACL,CAAC;CAoBJ;AAvFD,kCAuFC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Adapter, Answerable, Question } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from './PageElement';
|
|
3
|
+
export declare abstract class PageElements<NativeElementContext = any, NativeElementList = any, NativeElement = any> {
|
|
4
|
+
protected readonly context: () => Promise<NativeElementContext> | NativeElementContext;
|
|
5
|
+
protected readonly locator: (root: NativeElementContext) => Promise<NativeElementList> | NativeElementList;
|
|
6
|
+
static of(childElements: Answerable<PageElements>, parentElement: Answerable<PageElement>): Question<Promise<PageElements>> & Adapter<PageElements>;
|
|
7
|
+
static locatedByCss(selector: Answerable<string>): Question<Promise<PageElements>> & Adapter<PageElements>;
|
|
8
|
+
static locatedByTagName(selector: Answerable<string>): Question<Promise<PageElements>> & Adapter<PageElements>;
|
|
9
|
+
static locatedByXPath(selector: Answerable<string>): Question<Promise<PageElements>> & Adapter<PageElements>;
|
|
10
|
+
constructor(context: () => Promise<NativeElementContext> | NativeElementContext, locator: (root: NativeElementContext) => Promise<NativeElementList> | NativeElementList);
|
|
11
|
+
abstract of(parent: PageElement): PageElements;
|
|
12
|
+
nativeElementList(): Promise<NativeElementList>;
|
|
13
|
+
abstract count(): Promise<number>;
|
|
14
|
+
abstract first(): Promise<PageElement<NativeElementContext, NativeElement>>;
|
|
15
|
+
abstract last(): Promise<PageElement<NativeElementContext, NativeElement>>;
|
|
16
|
+
abstract get(index: number): Promise<PageElement<NativeElementContext, NativeElement>>;
|
|
17
|
+
abstract map<O>(fn: (element: PageElement, index?: number, elements?: PageElements) => Promise<O> | O): Promise<O[]>;
|
|
18
|
+
abstract filter(fn: (element: PageElement, index?: number) => Promise<boolean> | boolean): PageElements;
|
|
19
|
+
abstract forEach(fn: (element: PageElement, index?: number) => Promise<void> | void): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageElements = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
const d = (0, core_1.format)({ markQuestions: false });
|
|
7
|
+
const f = (0, core_1.format)({ markQuestions: true });
|
|
8
|
+
class PageElements {
|
|
9
|
+
constructor(context, locator) {
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.locator = locator;
|
|
12
|
+
}
|
|
13
|
+
static of(childElements, parentElement) {
|
|
14
|
+
return core_1.Question.about(d `${childElements} of ${parentElement})`, async (actor) => {
|
|
15
|
+
const children = await actor.answer(childElements);
|
|
16
|
+
const parent = await actor.answer(parentElement);
|
|
17
|
+
return children.of(parent);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
static locatedByCss(selector) {
|
|
21
|
+
return core_1.Question.about(f `page elements located by css (${selector})`, async (actor) => {
|
|
22
|
+
const value = await actor.answer(selector);
|
|
23
|
+
return abilities_1.BrowseTheWeb.as(actor).findAllByCss(value);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static locatedByTagName(selector) {
|
|
27
|
+
return core_1.Question.about(f `page elements located by tag name (${selector})`, async (actor) => {
|
|
28
|
+
const tagNameSelector = await actor.answer(selector);
|
|
29
|
+
return abilities_1.BrowseTheWeb.as(actor).findAllByTagName(tagNameSelector);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static locatedByXPath(selector) {
|
|
33
|
+
return core_1.Question.about(f `page elements located by xpath (${selector})`, async (actor) => {
|
|
34
|
+
const xpathSelector = await actor.answer(selector);
|
|
35
|
+
return abilities_1.BrowseTheWeb.as(actor).findAllByXPath(xpathSelector);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async nativeElementList() {
|
|
39
|
+
try {
|
|
40
|
+
const context = await this.context();
|
|
41
|
+
return this.locator(context);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new core_1.LogicError(`Couldn't find elements`, error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.PageElements = PageElements;
|
|
49
|
+
//# sourceMappingURL=PageElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageElements.js","sourceRoot":"","sources":["../../../src/screenplay/models/PageElements.ts"],"names":[],"mappings":";;;AAAA,4CAAsF;AAEtF,4CAA4C;AAG5C,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,MAAM,CAAC,GAAG,IAAA,aAAM,EAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AAE1C,MAAsB,YAAY;IAiC9B,YACuB,OAAmE,EACnE,OAAuF;QADvF,YAAO,GAAP,OAAO,CAA4D;QACnE,YAAO,GAAP,OAAO,CAAgF;IAE9G,CAAC;IAlCD,MAAM,CAAC,EAAE,CAAC,aAAuC,EAAE,aAAsC;QACrF,OAAO,eAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAI,aAAc,OAAQ,aAAc,GAAG,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC/E,MAAM,QAAQ,GAAI,MAAM,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACpD,MAAM,MAAM,GAAM,MAAM,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAEpD,OAAO,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACP,CAAC;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AAwB,EAAE,KAAK,CAAC,CAAC;SACzD;IACL,CAAC;CAYJ;AA7DD,oCA6DC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Cookie"), exports);
|
|
14
|
+
__exportStar(require("./CookieData"), exports);
|
|
15
|
+
__exportStar(require("./ModalDialog"), exports);
|
|
16
|
+
__exportStar(require("./Page"), exports);
|
|
17
|
+
__exportStar(require("./PageElement"), exports);
|
|
18
|
+
__exportStar(require("./PageElements"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,gDAA8B;AAC9B,yCAAuB;AACvB,gDAA8B;AAC9B,iDAA+B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Answerable, AnswersQuestions, MetaQuestion, Question, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from '../models';
|
|
3
|
+
import { ElementQuestion } from './ElementQuestion';
|
|
4
|
+
/**
|
|
5
|
+
* @desc
|
|
6
|
+
* Returns the value of the given HTML attribute of a given {@link WebElement},
|
|
7
|
+
* represented by Answerable<{@link @wdio/types~Element}>
|
|
8
|
+
*
|
|
9
|
+
* @example <caption>Example widget</caption>
|
|
10
|
+
* <ul id="shopping-list" data-items-left="2">
|
|
11
|
+
* <li data-state="bought">Coffee<li>
|
|
12
|
+
* <li data-state="buy">Honey<li>
|
|
13
|
+
* <li data-state="buy">Chocolate<li>
|
|
14
|
+
* </ul>
|
|
15
|
+
*
|
|
16
|
+
* @example <caption>Retrieve a HTML attribute of a given WebElement</caption>
|
|
17
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
18
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
19
|
+
* import { Attribute, by, BrowseTheWeb, Target } from '@serenity-js/webdriverio';
|
|
20
|
+
*
|
|
21
|
+
* const shoppingList = () =>
|
|
22
|
+
* Target.the('shopping list').located(by.id('shopping-list'))
|
|
23
|
+
*
|
|
24
|
+
* actorCalled('Lisa')
|
|
25
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
26
|
+
* .attemptsTo(
|
|
27
|
+
* Ensure.that(Attribute.called('data-items-left').of(shoppingList()), equals('2')),
|
|
28
|
+
* )
|
|
29
|
+
*
|
|
30
|
+
* @example <caption>Find WebElements with a given attribute</caption>
|
|
31
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
32
|
+
* import { Ensure, includes } from '@serenity-js/assertions';
|
|
33
|
+
* import { Attribute, BrowseTheWeb, by, Target } from '@serenity-js/webdriverio';
|
|
34
|
+
*
|
|
35
|
+
* class ShoppingList {
|
|
36
|
+
* static items = () =>
|
|
37
|
+
* Target.all('items')
|
|
38
|
+
* .located(by.css('#shopping-list li'))
|
|
39
|
+
*
|
|
40
|
+
* static outstandingItems = () =>
|
|
41
|
+
* ShoppingList.items
|
|
42
|
+
* .where(Attribute.called('data-state'), includes('buy'))
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* actorCalled('Lisa')
|
|
46
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
47
|
+
* .attemptsTo(
|
|
48
|
+
* Ensure.that(
|
|
49
|
+
* Text.ofAll(ShoppingList.outstandingItems()),
|
|
50
|
+
* equals([ 'Honey', 'Chocolate' ])
|
|
51
|
+
* ),
|
|
52
|
+
* )
|
|
53
|
+
*
|
|
54
|
+
* @extends {ElementQuestion}
|
|
55
|
+
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
56
|
+
*/
|
|
57
|
+
export declare class Attribute extends ElementQuestion<Promise<string>> implements MetaQuestion<Answerable<PageElement>, Promise<string>> {
|
|
58
|
+
private readonly name;
|
|
59
|
+
private readonly element?;
|
|
60
|
+
/**
|
|
61
|
+
* @param {Answerable<string>} name
|
|
62
|
+
* @returns {Attribute}
|
|
63
|
+
*/
|
|
64
|
+
static called(name: Answerable<string>): Attribute;
|
|
65
|
+
/**
|
|
66
|
+
* @param {Answerable<string>} name
|
|
67
|
+
* @param {@serenity-js/core/lib/screenplay~Answerable<Element>} [element]
|
|
68
|
+
*/
|
|
69
|
+
constructor(name: Answerable<string>, element?: Answerable<PageElement>);
|
|
70
|
+
/**
|
|
71
|
+
* @desc
|
|
72
|
+
* Resolves to the value of a HTML attribute of the `target` element,
|
|
73
|
+
* located in the context of a `parent` element.
|
|
74
|
+
*
|
|
75
|
+
* @param {Answerable<PageElement>} parent
|
|
76
|
+
* @returns {Question<Promise<string[]>>}
|
|
77
|
+
*
|
|
78
|
+
* @see {@link Target.all}
|
|
79
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
80
|
+
*/
|
|
81
|
+
of(parent: Answerable<PageElement>): Question<Promise<string>>;
|
|
82
|
+
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string>;
|
|
83
|
+
}
|