@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,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Selected = void 0;
|
|
4
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Represents options and values selected in a
|
|
9
|
+
* [HTML `<select>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select).
|
|
10
|
+
*
|
|
11
|
+
* @see {@link Select}
|
|
12
|
+
*/
|
|
13
|
+
class Selected {
|
|
14
|
+
/**
|
|
15
|
+
* @desc
|
|
16
|
+
* Represents the value of a single option selected in a
|
|
17
|
+
* [HTML `<select>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select).
|
|
18
|
+
*
|
|
19
|
+
* @example <caption>Example widget</caption>
|
|
20
|
+
* <select data-test='countries'>
|
|
21
|
+
* <option value='UK'>United Kingdom</option>
|
|
22
|
+
* <option value='PL'>Poland</option>
|
|
23
|
+
* <option value='US'>United States</option>
|
|
24
|
+
* </select>
|
|
25
|
+
*
|
|
26
|
+
* @example <caption>Lean Page Object</caption>
|
|
27
|
+
* import { Target } from '@serenity-js/protractor';
|
|
28
|
+
* import { browser, by } from 'protractor';
|
|
29
|
+
*
|
|
30
|
+
* class Countries {
|
|
31
|
+
* static dropdown = Target.the('countries dropdown')
|
|
32
|
+
* .located(by.css('[data-test="countries"]'));
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* @example <caption>Retrieving the selected value</caption>
|
|
36
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
37
|
+
* import { Accept, BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
|
|
38
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
39
|
+
* import { protractor } from 'protractor';
|
|
40
|
+
*
|
|
41
|
+
* actorCalled('Nick')
|
|
42
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
43
|
+
* .attemptsTo(
|
|
44
|
+
* Select.value('UK').from(Countries.dropdown),
|
|
45
|
+
* Ensure.that(Selected.valueOf(Countries.dropdown), equals('UK')),
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* @param {Answerable<PageElement>} pageElement
|
|
49
|
+
* A {@link PageElement} identifying the `<select>` element of interest
|
|
50
|
+
*
|
|
51
|
+
* @returns {Question<Promise<string>>}
|
|
52
|
+
*
|
|
53
|
+
* @see {@link Select.value}
|
|
54
|
+
*/
|
|
55
|
+
static valueOf(pageElement) {
|
|
56
|
+
return models_1.PageElement.locatedByCss('option:checked')
|
|
57
|
+
.of(pageElement)
|
|
58
|
+
.value()
|
|
59
|
+
.describedAs((0, io_1.formatted) `value selected in ${pageElement}`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @desc
|
|
63
|
+
* Represents values of options selected in a
|
|
64
|
+
* [HTML `<select multiple>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attr-multiple)
|
|
65
|
+
*
|
|
66
|
+
* @example <caption>Example widget</caption>
|
|
67
|
+
* <select multiple data-test='countries'>
|
|
68
|
+
* <option value='UK'>United Kingdom</option>
|
|
69
|
+
* <option value='PL'>Poland</option>
|
|
70
|
+
* <option value='US'>United States</option>
|
|
71
|
+
* </select>
|
|
72
|
+
*
|
|
73
|
+
* @example <caption>Lean Page Object</caption>
|
|
74
|
+
* import { Target } from '@serenity-js/protractor';
|
|
75
|
+
* import { browser, by } from 'protractor';
|
|
76
|
+
*
|
|
77
|
+
* class Countries {
|
|
78
|
+
* static dropdown = Target.the('countries dropdown')
|
|
79
|
+
* .located(by.css('[data-test="countries"]'));
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* @example <caption>Retrieving the selected value</caption>
|
|
83
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
84
|
+
* import { Accept, BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
|
|
85
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
86
|
+
* import { protractor } from 'protractor';
|
|
87
|
+
*
|
|
88
|
+
* actorCalled('Nick')
|
|
89
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
90
|
+
* .attemptsTo(
|
|
91
|
+
* Select.values('UK').from(Countries.dropdown),
|
|
92
|
+
* Ensure.that(Selected.valuesOf(Countries.dropdown), equals([ 'UK' ])),
|
|
93
|
+
* );
|
|
94
|
+
*
|
|
95
|
+
* @param {Answerable<PageElement>} pageElement
|
|
96
|
+
* A {@link Target} identifying the `<select>` element of interest
|
|
97
|
+
*
|
|
98
|
+
* @returns {Question<Promise<string[]>>}
|
|
99
|
+
*
|
|
100
|
+
* @see {@link Select.values}
|
|
101
|
+
*/
|
|
102
|
+
static valuesOf(pageElement) {
|
|
103
|
+
return models_1.PageElements.locatedByCss('option:checked')
|
|
104
|
+
.of(pageElement)
|
|
105
|
+
.map(item => item.value())
|
|
106
|
+
.describedAs((0, io_1.formatted) `values selected in ${pageElement}`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @desc
|
|
110
|
+
* Represents a single option selected in a
|
|
111
|
+
* [HTML `<select>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attr-multiple)
|
|
112
|
+
*
|
|
113
|
+
* @example <caption>Example widget</caption>
|
|
114
|
+
* <select data-test='countries'>
|
|
115
|
+
* <option value='UK'>United Kingdom</option>
|
|
116
|
+
* <option value='PL'>Poland</option>
|
|
117
|
+
* <option value='US'>United States</option>
|
|
118
|
+
* </select>
|
|
119
|
+
*
|
|
120
|
+
* @example <caption>Lean Page Object</caption>
|
|
121
|
+
* import { Target } from '@serenity-js/protractor';
|
|
122
|
+
* import { browser, by } from 'protractor';
|
|
123
|
+
*
|
|
124
|
+
* class Countries {
|
|
125
|
+
* static dropdown = Target.the('countries dropdown')
|
|
126
|
+
* .located(by.css('[data-test="countries"]'));
|
|
127
|
+
* }
|
|
128
|
+
*
|
|
129
|
+
* @example <caption>Retrieving the selected value</caption>
|
|
130
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
131
|
+
* import { Accept, BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
|
|
132
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
133
|
+
* import { protractor } from 'protractor';
|
|
134
|
+
*
|
|
135
|
+
* actorCalled('Nick')
|
|
136
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
137
|
+
* .attemptsTo(
|
|
138
|
+
* Select.option('Poland').from(Countries.dropdown),
|
|
139
|
+
* Ensure.that(
|
|
140
|
+
* Selected.optionIn(Countries.dropdown),
|
|
141
|
+
* equals('Poland')
|
|
142
|
+
* ),
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* @param {Answerable<PageElement>} pageElement
|
|
146
|
+
* A {@link Target} identifying the `<select>` element of interest
|
|
147
|
+
*
|
|
148
|
+
* @returns {Question<Promise<string>>}
|
|
149
|
+
*
|
|
150
|
+
* @see {@link Select.option}
|
|
151
|
+
*/
|
|
152
|
+
static optionIn(pageElement) {
|
|
153
|
+
return models_1.PageElement.locatedByCss('option:checked')
|
|
154
|
+
.of(pageElement)
|
|
155
|
+
.text()
|
|
156
|
+
.describedAs((0, io_1.formatted) `option selected in ${pageElement}`);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @desc
|
|
160
|
+
* Represents options selected in a
|
|
161
|
+
* [HTML `<select multiple>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attr-multiple)
|
|
162
|
+
*
|
|
163
|
+
* @example <caption>Example widget</caption>
|
|
164
|
+
* <select multiple data-test='countries'>
|
|
165
|
+
* <option value='UK'>United Kingdom</option>
|
|
166
|
+
* <option value='PL'>Poland</option>
|
|
167
|
+
* <option value='US'>United States</option>
|
|
168
|
+
* </select>
|
|
169
|
+
*
|
|
170
|
+
* @example <caption>Lean Page Object</caption>
|
|
171
|
+
* import { Target } from '@serenity-js/protractor';
|
|
172
|
+
* import { browser, by } from 'protractor';
|
|
173
|
+
*
|
|
174
|
+
* class Countries {
|
|
175
|
+
* static dropdown = Target.the('countries dropdown')
|
|
176
|
+
* .located(by.css('[data-test="countries"]'));
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* @example <caption>Retrieving the selected value</caption>
|
|
180
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
181
|
+
* import { Accept, BrowseTheWeb, Select, Selected } from '@serenity-js/protractor';
|
|
182
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
183
|
+
* import { protractor } from 'protractor';
|
|
184
|
+
*
|
|
185
|
+
* actorCalled('Nick')
|
|
186
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
187
|
+
* .attemptsTo(
|
|
188
|
+
* Select.options('Poland', 'United States').from(Countries.dropdown),
|
|
189
|
+
* Ensure.that(
|
|
190
|
+
* Selected.optionsIn(Countries.dropdown),
|
|
191
|
+
* equals([ 'Poland', 'United States' ])
|
|
192
|
+
* ),
|
|
193
|
+
* );
|
|
194
|
+
*
|
|
195
|
+
* @param {Answerable<PageElement>} pageElement
|
|
196
|
+
* A {@link Target} identifying the `<select>` element of interest
|
|
197
|
+
*
|
|
198
|
+
* @returns {Question<Promise<string[]>>}
|
|
199
|
+
*
|
|
200
|
+
* @see {@link Select.options}
|
|
201
|
+
*/
|
|
202
|
+
static optionsIn(pageElement) {
|
|
203
|
+
return models_1.PageElements.locatedByCss('option:checked')
|
|
204
|
+
.of(pageElement)
|
|
205
|
+
.map(item => item.text())
|
|
206
|
+
.describedAs((0, io_1.formatted) `options selected in ${pageElement}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.Selected = Selected;
|
|
210
|
+
//# sourceMappingURL=Selected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Selected.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Selected.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAErD,sCAAsD;AAEtD;;;;;;GAMG;AACH,MAAa,QAAQ;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAAM,CAAC,OAAO,CAAC,WAAoC;QAC/C,OAAO,oBAAW,CAAC,YAAY,CAAC,gBAAgB,CAAC;aAC5C,EAAE,CAAC,WAAW,CAAC;aACf,KAAK,EAAE;aACP,WAAW,CAAC,IAAA,cAAS,EAAC,qBAAsB,WAAY,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAoC;QAChD,OAAO,qBAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC;aAC7C,EAAE,CAAC,WAAW,CAAC;aACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;aACzB,WAAW,CAAC,IAAA,cAAS,EAAC,sBAAuB,WAAY,EAAE,CAAgC,CAAC;IACrG,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,MAAM,CAAC,QAAQ,CAAC,WAAoC;QAChD,OAAO,oBAAW,CAAC,YAAY,CAAC,gBAAgB,CAAC;aAC5C,EAAE,CAAC,WAAW,CAAC;aACf,IAAI,EAAE;aACN,WAAW,CAAC,IAAA,cAAS,EAAC,sBAAuB,WAAY,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,MAAM,CAAC,SAAS,CAAC,WAAoC;QACjD,OAAO,qBAAY,CAAC,YAAY,CAAC,gBAAgB,CAAC;aAC7C,EAAE,CAAC,WAAW,CAAC;aACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aACxB,WAAW,CAAC,IAAA,cAAS,EAAC,uBAAwB,WAAY,EAAE,CAAgC,CAAC;IACtG,CAAC;CACJ;AAvMD,4BAuMC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Adapter, Answerable, MetaQuestion, Question } from '@serenity-js/core';
|
|
2
|
+
import { PageElement, PageElements } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Resolves to the visible (i.e. not hidden by CSS) `innerText` of:
|
|
6
|
+
* - a given {@link WebElement}, represented by Answerable<{@link @wdio/types~Element}>
|
|
7
|
+
* - a group of {@link WebElement}s, represented by Answerable<{@link @wdio/types~ElementList}>
|
|
8
|
+
*
|
|
9
|
+
* The result includes the visible text of any sub-elements, without any leading or trailing whitespace.
|
|
10
|
+
*
|
|
11
|
+
* @example <caption>Example widget</caption>
|
|
12
|
+
* <h1>Shopping list</h1>
|
|
13
|
+
* <ul id="shopping-list">
|
|
14
|
+
* <li>Coffee<li>
|
|
15
|
+
* <li class="bought">Honey<li>
|
|
16
|
+
* <li>Chocolate<li>
|
|
17
|
+
* </ul>
|
|
18
|
+
*
|
|
19
|
+
* @example <caption>Retrieve text of a single element</caption>
|
|
20
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
21
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
22
|
+
* import { BrowseTheWeb, by, Target, Text } from '@serenity-js/webdriverio';
|
|
23
|
+
*
|
|
24
|
+
* const header = () =>
|
|
25
|
+
* Target.the('header').located(by.tagName('h1'))
|
|
26
|
+
*
|
|
27
|
+
* actorCalled('Lisa')
|
|
28
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
29
|
+
* .attemptsTo(
|
|
30
|
+
* Ensure.that(Text.of(header()), equals('Shopping list')),
|
|
31
|
+
* )
|
|
32
|
+
*
|
|
33
|
+
* @example <caption>Retrieve text of a multiple elements</caption>
|
|
34
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
35
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
36
|
+
* import { BrowseTheWeb, by, Target, Text } from '@serenity-js/webdriverio';
|
|
37
|
+
*
|
|
38
|
+
* const shoppingListItems = () =>
|
|
39
|
+
* Target.the('shopping list items').located(by.css('#shopping-list li'))
|
|
40
|
+
*
|
|
41
|
+
* actorCalled('Lisa')
|
|
42
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
43
|
+
* .attemptsTo(
|
|
44
|
+
* Ensure.that(
|
|
45
|
+
* Text.ofAll(shoppingListItems()),
|
|
46
|
+
* equals([ 'Coffee', 'Honey', 'Chocolate' ])
|
|
47
|
+
* ),
|
|
48
|
+
* )
|
|
49
|
+
*
|
|
50
|
+
* @example <caption>Find element with matching text</caption>
|
|
51
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
52
|
+
* import { contain, Ensure } from '@serenity-js/assertions';
|
|
53
|
+
* import { BrowseTheWeb, by, CssClasses, Target, Text } from '@serenity-js/webdriverio';
|
|
54
|
+
*
|
|
55
|
+
* const shoppingListItemCalled = (name: string) =>
|
|
56
|
+
* Target.the('shopping list items').located(by.css('#shopping-list li'))
|
|
57
|
+
* .where(Text, equals(name))
|
|
58
|
+
* .first()
|
|
59
|
+
*
|
|
60
|
+
* actorCalled('Lisa')
|
|
61
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
62
|
+
* .attemptsTo(
|
|
63
|
+
* Ensure.that(
|
|
64
|
+
* CssClasses.of(shoppingListItemCalled('Honey)),
|
|
65
|
+
* contain('bought')
|
|
66
|
+
* ),
|
|
67
|
+
* )
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
* @see {@link Target}
|
|
71
|
+
*/
|
|
72
|
+
export declare class Text {
|
|
73
|
+
/**
|
|
74
|
+
* @desc
|
|
75
|
+
* Retrieves text of a single {@link WebElement},
|
|
76
|
+
* represented by Answerable<{@link @wdio/types~Element}>.
|
|
77
|
+
*
|
|
78
|
+
* @param {Answerable<PageElement>} element
|
|
79
|
+
* @returns {Question<Promise<string>> & MetaQuestion<Answerable<PageElement>, Promise<string>>}
|
|
80
|
+
*
|
|
81
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
82
|
+
*/
|
|
83
|
+
static of(element: Answerable<PageElement>): Question<Promise<string>> & // eslint-disable-line @typescript-eslint/indent
|
|
84
|
+
MetaQuestion<Answerable<PageElement>, Promise<string>> & // eslint-disable-line @typescript-eslint/indent
|
|
85
|
+
Adapter<string>;
|
|
86
|
+
/**
|
|
87
|
+
* @desc
|
|
88
|
+
* Retrieves text of a group of {@link WebElement}s,
|
|
89
|
+
* represented by Answerable<{@link @wdio/types~ElementList}>
|
|
90
|
+
*
|
|
91
|
+
* @param {Answerable<PageElements>} elements
|
|
92
|
+
* @returns {Question<Promise<string[]>> & MetaQuestion<Answerable<PageElement>, Promise<string[]>>}
|
|
93
|
+
*
|
|
94
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
95
|
+
*/
|
|
96
|
+
static ofAll(elements: Answerable<PageElements>): Question<Promise<string[]>> & // eslint-disable-line @typescript-eslint/indent
|
|
97
|
+
MetaQuestion<Answerable<PageElement>, Promise<string[]>> & // eslint-disable-line @typescript-eslint/indent
|
|
98
|
+
Adapter<string[]>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Text = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const ElementQuestion_1 = require("./ElementQuestion");
|
|
7
|
+
/**
|
|
8
|
+
* @desc
|
|
9
|
+
* Resolves to the visible (i.e. not hidden by CSS) `innerText` of:
|
|
10
|
+
* - a given {@link WebElement}, represented by Answerable<{@link @wdio/types~Element}>
|
|
11
|
+
* - a group of {@link WebElement}s, represented by Answerable<{@link @wdio/types~ElementList}>
|
|
12
|
+
*
|
|
13
|
+
* The result includes the visible text of any sub-elements, without any leading or trailing whitespace.
|
|
14
|
+
*
|
|
15
|
+
* @example <caption>Example widget</caption>
|
|
16
|
+
* <h1>Shopping list</h1>
|
|
17
|
+
* <ul id="shopping-list">
|
|
18
|
+
* <li>Coffee<li>
|
|
19
|
+
* <li class="bought">Honey<li>
|
|
20
|
+
* <li>Chocolate<li>
|
|
21
|
+
* </ul>
|
|
22
|
+
*
|
|
23
|
+
* @example <caption>Retrieve text of a single element</caption>
|
|
24
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
25
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
26
|
+
* import { BrowseTheWeb, by, Target, Text } from '@serenity-js/webdriverio';
|
|
27
|
+
*
|
|
28
|
+
* const header = () =>
|
|
29
|
+
* Target.the('header').located(by.tagName('h1'))
|
|
30
|
+
*
|
|
31
|
+
* actorCalled('Lisa')
|
|
32
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
33
|
+
* .attemptsTo(
|
|
34
|
+
* Ensure.that(Text.of(header()), equals('Shopping list')),
|
|
35
|
+
* )
|
|
36
|
+
*
|
|
37
|
+
* @example <caption>Retrieve text of a multiple elements</caption>
|
|
38
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
39
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
40
|
+
* import { BrowseTheWeb, by, Target, Text } from '@serenity-js/webdriverio';
|
|
41
|
+
*
|
|
42
|
+
* const shoppingListItems = () =>
|
|
43
|
+
* Target.the('shopping list items').located(by.css('#shopping-list li'))
|
|
44
|
+
*
|
|
45
|
+
* actorCalled('Lisa')
|
|
46
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
47
|
+
* .attemptsTo(
|
|
48
|
+
* Ensure.that(
|
|
49
|
+
* Text.ofAll(shoppingListItems()),
|
|
50
|
+
* equals([ 'Coffee', 'Honey', 'Chocolate' ])
|
|
51
|
+
* ),
|
|
52
|
+
* )
|
|
53
|
+
*
|
|
54
|
+
* @example <caption>Find element with matching text</caption>
|
|
55
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
56
|
+
* import { contain, Ensure } from '@serenity-js/assertions';
|
|
57
|
+
* import { BrowseTheWeb, by, CssClasses, Target, Text } from '@serenity-js/webdriverio';
|
|
58
|
+
*
|
|
59
|
+
* const shoppingListItemCalled = (name: string) =>
|
|
60
|
+
* Target.the('shopping list items').located(by.css('#shopping-list li'))
|
|
61
|
+
* .where(Text, equals(name))
|
|
62
|
+
* .first()
|
|
63
|
+
*
|
|
64
|
+
* actorCalled('Lisa')
|
|
65
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
66
|
+
* .attemptsTo(
|
|
67
|
+
* Ensure.that(
|
|
68
|
+
* CssClasses.of(shoppingListItemCalled('Honey)),
|
|
69
|
+
* contain('bought')
|
|
70
|
+
* ),
|
|
71
|
+
* )
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @see {@link Target}
|
|
75
|
+
*/
|
|
76
|
+
class Text {
|
|
77
|
+
/**
|
|
78
|
+
* @desc
|
|
79
|
+
* Retrieves text of a single {@link WebElement},
|
|
80
|
+
* represented by Answerable<{@link @wdio/types~Element}>.
|
|
81
|
+
*
|
|
82
|
+
* @param {Answerable<PageElement>} element
|
|
83
|
+
* @returns {Question<Promise<string>> & MetaQuestion<Answerable<PageElement>, Promise<string>>}
|
|
84
|
+
*
|
|
85
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
86
|
+
*/
|
|
87
|
+
static of(element) {
|
|
88
|
+
return (0, core_1.createAdapter)(new TextOfSingleElement(element));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @desc
|
|
92
|
+
* Retrieves text of a group of {@link WebElement}s,
|
|
93
|
+
* represented by Answerable<{@link @wdio/types~ElementList}>
|
|
94
|
+
*
|
|
95
|
+
* @param {Answerable<PageElements>} elements
|
|
96
|
+
* @returns {Question<Promise<string[]>> & MetaQuestion<Answerable<PageElement>, Promise<string[]>>}
|
|
97
|
+
*
|
|
98
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
99
|
+
*/
|
|
100
|
+
static ofAll(elements) {
|
|
101
|
+
return (0, core_1.createAdapter)(new TextOfMultipleElements(elements));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.Text = Text;
|
|
105
|
+
class TextOfSingleElement extends ElementQuestion_1.ElementQuestion {
|
|
106
|
+
constructor(element) {
|
|
107
|
+
super(`the text of ${element}`);
|
|
108
|
+
this.element = element;
|
|
109
|
+
}
|
|
110
|
+
of(parent) {
|
|
111
|
+
return new TextOfSingleElement(models_1.PageElement.of(this.element, parent));
|
|
112
|
+
}
|
|
113
|
+
async answeredBy(actor) {
|
|
114
|
+
const element = await this.resolve(actor, this.element);
|
|
115
|
+
return element.text();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
class TextOfMultipleElements extends ElementQuestion_1.ElementQuestion {
|
|
119
|
+
constructor(elements) {
|
|
120
|
+
super(`the text of ${elements}`);
|
|
121
|
+
this.elements = elements;
|
|
122
|
+
}
|
|
123
|
+
of(parent) {
|
|
124
|
+
return new TextOfMultipleElements(models_1.PageElements.of(this.elements, parent));
|
|
125
|
+
}
|
|
126
|
+
async answeredBy(actor) {
|
|
127
|
+
const elements = await this.resolve(actor, this.elements);
|
|
128
|
+
return elements.map(element => element.text());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Text.ts"],"names":[],"mappings":";;;AAAA,4CAAgI;AAEhI,sCAAsD;AACtD,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAa,IAAI;IAEb;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,CAAC,OAAgC;QAKtC,OAAO,IAAA,oBAAa,EAChB,IAAI,mBAAmB,CAAC,OAAO,CAAC,CACnC,CAAC;IACN,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,QAAkC;QAK3C,OAAO,IAAA,oBAAa,EAChB,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CACvC,CAAC;IACN,CAAC;CACJ;AAzCD,oBAyCC;AAED,MAAM,mBACF,SAAQ,iCAAgC;IAGxC,YAA6B,OAAgC;QACzD,KAAK,CAAC,eAAgB,OAAQ,EAAE,CAAC,CAAC;QADT,YAAO,GAAP,OAAO,CAAyB;IAE7D,CAAC;IAED,EAAE,CAAC,MAA+B;QAC9B,OAAO,IAAI,mBAAmB,CAAC,oBAAW,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAuC;QACpD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAExD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;CACJ;AAED,MAAM,sBACF,SAAQ,iCAAkC;IAG1C,YAA6B,QAAkC;QAC3D,KAAK,CAAC,eAAgB,QAAS,EAAE,CAAC,CAAC;QADV,aAAQ,GAAR,QAAQ,CAA0B;IAE/D,CAAC;IAED,EAAE,CAAC,MAA+B;QAC9B,OAAO,IAAI,sBAAsB,CAAC,qBAAY,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAuC;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACJ"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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` attribute of a given {@link WebElement},
|
|
7
|
+
* represented by Answerable<{@link @wdio/types~Element}>
|
|
8
|
+
*
|
|
9
|
+
* @example <caption>Example widget</caption>
|
|
10
|
+
* <input type="text" id="username" value="Alice" />
|
|
11
|
+
*
|
|
12
|
+
* @example <caption>Retrieve CSS classes of a given WebElement</caption>
|
|
13
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
14
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
15
|
+
* import { BrowseTheWeb, by, Value, Target } from '@serenity-js/webdriverio';
|
|
16
|
+
*
|
|
17
|
+
* const usernameField = () =>
|
|
18
|
+
* Target.the('username field').located(by.id('username'))
|
|
19
|
+
*
|
|
20
|
+
* actorCalled('Lisa')
|
|
21
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
22
|
+
* .attemptsTo(
|
|
23
|
+
* Ensure.that(Value.of(usernameField), equals('Alice')),
|
|
24
|
+
* )
|
|
25
|
+
*
|
|
26
|
+
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
27
|
+
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
28
|
+
*/
|
|
29
|
+
export declare class Value extends ElementQuestion<Promise<string>> implements MetaQuestion<Answerable<PageElement>, Promise<string>> {
|
|
30
|
+
private readonly element;
|
|
31
|
+
/**
|
|
32
|
+
* @param {Answerable<PageElement>} element
|
|
33
|
+
* @returns {Value}
|
|
34
|
+
*/
|
|
35
|
+
static of(element: Answerable<PageElement>): Question<Promise<string>> & MetaQuestion<Answerable<PageElement>, Promise<string>>;
|
|
36
|
+
/**
|
|
37
|
+
* @param {Answerable<PageElement>} element
|
|
38
|
+
*/
|
|
39
|
+
constructor(element: Answerable<PageElement>);
|
|
40
|
+
/**
|
|
41
|
+
* @desc
|
|
42
|
+
* Resolves to the value of a given [`input`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input)
|
|
43
|
+
* {@link WebElement}, located in the context of a `parent` element.
|
|
44
|
+
*
|
|
45
|
+
* @param {Answerable<PageElement>} parent
|
|
46
|
+
* @returns {Question<Promise<string>>}
|
|
47
|
+
*
|
|
48
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
49
|
+
*/
|
|
50
|
+
of(parent: Answerable<PageElement>): Question<Promise<string>>;
|
|
51
|
+
/**
|
|
52
|
+
* @desc
|
|
53
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
54
|
+
* answer this {@link @serenity-js/core/lib/screenplay~Question}.
|
|
55
|
+
*
|
|
56
|
+
* @param {AnswersQuestions & UsesAbilities} actor
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
*
|
|
59
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
60
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
61
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
62
|
+
*/
|
|
63
|
+
answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Value = void 0;
|
|
4
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const ElementQuestion_1 = require("./ElementQuestion");
|
|
7
|
+
/**
|
|
8
|
+
* @desc
|
|
9
|
+
* Returns the `value` attribute of a given {@link WebElement},
|
|
10
|
+
* represented by Answerable<{@link @wdio/types~Element}>
|
|
11
|
+
*
|
|
12
|
+
* @example <caption>Example widget</caption>
|
|
13
|
+
* <input type="text" id="username" value="Alice" />
|
|
14
|
+
*
|
|
15
|
+
* @example <caption>Retrieve CSS classes of a given WebElement</caption>
|
|
16
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
17
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
18
|
+
* import { BrowseTheWeb, by, Value, Target } from '@serenity-js/webdriverio';
|
|
19
|
+
*
|
|
20
|
+
* const usernameField = () =>
|
|
21
|
+
* Target.the('username field').located(by.id('username'))
|
|
22
|
+
*
|
|
23
|
+
* actorCalled('Lisa')
|
|
24
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
25
|
+
* .attemptsTo(
|
|
26
|
+
* Ensure.that(Value.of(usernameField), equals('Alice')),
|
|
27
|
+
* )
|
|
28
|
+
*
|
|
29
|
+
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
30
|
+
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
31
|
+
*/
|
|
32
|
+
class Value extends ElementQuestion_1.ElementQuestion {
|
|
33
|
+
/**
|
|
34
|
+
* @param {Answerable<PageElement>} element
|
|
35
|
+
*/
|
|
36
|
+
constructor(element) {
|
|
37
|
+
super((0, io_1.formatted) `the value of ${element}`);
|
|
38
|
+
this.element = element;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param {Answerable<PageElement>} element
|
|
42
|
+
* @returns {Value}
|
|
43
|
+
*/
|
|
44
|
+
static of(element) {
|
|
45
|
+
return new Value(element);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @desc
|
|
49
|
+
* Resolves to the value of a given [`input`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input)
|
|
50
|
+
* {@link WebElement}, located in the context of a `parent` element.
|
|
51
|
+
*
|
|
52
|
+
* @param {Answerable<PageElement>} parent
|
|
53
|
+
* @returns {Question<Promise<string>>}
|
|
54
|
+
*
|
|
55
|
+
* @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
56
|
+
*/
|
|
57
|
+
of(parent) {
|
|
58
|
+
return new Value(models_1.PageElement.of(this.element, parent));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @desc
|
|
62
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
63
|
+
* answer this {@link @serenity-js/core/lib/screenplay~Question}.
|
|
64
|
+
*
|
|
65
|
+
* @param {AnswersQuestions & UsesAbilities} actor
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
*
|
|
68
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
69
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
70
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
71
|
+
*/
|
|
72
|
+
async answeredBy(actor) {
|
|
73
|
+
const element = await this.resolve(actor, this.element);
|
|
74
|
+
return element.value();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Value = Value;
|
|
78
|
+
//# sourceMappingURL=Value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Value.js","sourceRoot":"","sources":["../../../src/screenplay/questions/Value.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAErD,sCAAwC;AACxC,uDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,KACT,SAAQ,iCAAgC;IAWxC;;OAEG;IACH,YAA6B,OAAgC;QACzD,KAAK,CAAC,IAAA,cAAS,EAAA,gBAAiB,OAAQ,EAAE,CAAC,CAAC;QADnB,YAAO,GAAP,OAAO,CAAyB;IAE7D,CAAC;IAbD;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAgC;QACtC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IASD;;;;;;;;;OASG;IACH,EAAE,CAAC,MAA+B;QAC9B,OAAO,IAAI,KAAK,CAAC,oBAAW,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,UAAU,CAAC,KAAuC;QACpD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAExD,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACJ;AAlDD,sBAkDC"}
|
|
@@ -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("./Attribute"), exports);
|
|
14
|
+
__exportStar(require("./CssClasses"), exports);
|
|
15
|
+
__exportStar(require("./LastScriptExecution"), exports);
|
|
16
|
+
__exportStar(require("./Selected"), exports);
|
|
17
|
+
__exportStar(require("./Text"), exports);
|
|
18
|
+
__exportStar(require("./Value"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA6B;AAC7B,wDAAsC;AACtC,6CAA2B;AAC3B,yCAAuB;AACvB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './photographer';
|
|
@@ -0,0 +1,14 @@
|
|
|
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("./photographer"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stage/crew/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B"}
|