@serenity-js/web 3.13.3 → 3.14.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 +31 -0
- package/lib/screenplay/abilities/BrowseTheWeb.js +1 -0
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +1 -1
- package/lib/screenplay/interactions/Clear.js +1 -0
- package/lib/screenplay/interactions/Clear.js.map +1 -1
- package/lib/screenplay/interactions/Click.js +1 -0
- package/lib/screenplay/interactions/Click.js.map +1 -1
- package/lib/screenplay/interactions/DoubleClick.js +1 -0
- package/lib/screenplay/interactions/DoubleClick.js.map +1 -1
- package/lib/screenplay/interactions/Enter.js +2 -0
- package/lib/screenplay/interactions/Enter.js.map +1 -1
- package/lib/screenplay/interactions/ExecuteScript.js +3 -0
- package/lib/screenplay/interactions/ExecuteScript.js.map +1 -1
- package/lib/screenplay/interactions/Hover.js +1 -0
- package/lib/screenplay/interactions/Hover.js.map +1 -1
- package/lib/screenplay/interactions/Navigate.js +1 -0
- package/lib/screenplay/interactions/Navigate.js.map +1 -1
- package/lib/screenplay/interactions/Press.js +5 -0
- package/lib/screenplay/interactions/Press.js.map +1 -1
- package/lib/screenplay/interactions/RightClick.js +1 -0
- package/lib/screenplay/interactions/RightClick.js.map +1 -1
- package/lib/screenplay/interactions/Scroll.js +1 -0
- package/lib/screenplay/interactions/Scroll.js.map +1 -1
- package/lib/screenplay/interactions/Switch.js +3 -0
- package/lib/screenplay/interactions/Switch.js.map +1 -1
- package/lib/screenplay/interactions/TakeScreenshot.js +1 -0
- package/lib/screenplay/interactions/TakeScreenshot.js.map +1 -1
- package/lib/screenplay/models/BrowsingSession.js +2 -3
- package/lib/screenplay/models/BrowsingSession.js.map +1 -1
- package/lib/screenplay/models/Cookie.js +2 -0
- package/lib/screenplay/models/Cookie.js.map +1 -1
- package/lib/screenplay/models/Key.js +55 -52
- package/lib/screenplay/models/Key.js.map +1 -1
- package/lib/screenplay/models/Locator.js +6 -6
- package/lib/screenplay/models/Locator.js.map +1 -1
- package/lib/screenplay/models/Page.js +4 -0
- package/lib/screenplay/models/Page.js.map +1 -1
- package/lib/screenplay/models/PageElement.js +1 -0
- package/lib/screenplay/models/PageElement.js.map +1 -1
- package/lib/screenplay/models/PageElementsLocator.js +2 -0
- package/lib/screenplay/models/PageElementsLocator.js.map +1 -1
- package/lib/screenplay/models/RootLocator.js +1 -5
- package/lib/screenplay/models/RootLocator.js.map +1 -1
- package/lib/screenplay/models/SelectOption.js +4 -0
- package/lib/screenplay/models/SelectOption.js.map +1 -1
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.js +1 -0
- package/lib/screenplay/models/dialogs/AcceptedModalDialog.js.map +1 -1
- package/lib/screenplay/models/dialogs/DismissedModalDialog.js +1 -0
- package/lib/screenplay/models/dialogs/DismissedModalDialog.js.map +1 -1
- package/lib/screenplay/models/dialogs/ModalDialogHandler.js +1 -0
- package/lib/screenplay/models/dialogs/ModalDialogHandler.js.map +1 -1
- package/lib/screenplay/models/selectors/ByCss.js +1 -0
- package/lib/screenplay/models/selectors/ByCss.js.map +1 -1
- package/lib/screenplay/models/selectors/ByCssContainingText.js +2 -0
- package/lib/screenplay/models/selectors/ByCssContainingText.js.map +1 -1
- package/lib/screenplay/models/selectors/ByDeepCss.js +1 -0
- package/lib/screenplay/models/selectors/ByDeepCss.js.map +1 -1
- package/lib/screenplay/models/selectors/ById.js +1 -0
- package/lib/screenplay/models/selectors/ById.js.map +1 -1
- package/lib/screenplay/models/selectors/ByTagName.js +1 -0
- package/lib/screenplay/models/selectors/ByTagName.js.map +1 -1
- package/lib/screenplay/models/selectors/ByXPath.js +1 -0
- package/lib/screenplay/models/selectors/ByXPath.js.map +1 -1
- package/lib/screenplay/questions/Attribute.d.ts +9 -9
- package/lib/screenplay/questions/Attribute.d.ts.map +1 -1
- package/lib/screenplay/questions/Attribute.js +10 -7
- package/lib/screenplay/questions/Attribute.js.map +1 -1
- package/lib/screenplay/questions/ComputedStyle.d.ts +140 -0
- package/lib/screenplay/questions/ComputedStyle.d.ts.map +1 -0
- package/lib/screenplay/questions/ComputedStyle.js +176 -0
- package/lib/screenplay/questions/ComputedStyle.js.map +1 -0
- package/lib/screenplay/questions/index.d.ts +1 -0
- package/lib/screenplay/questions/index.d.ts.map +1 -1
- package/lib/screenplay/questions/index.js +1 -0
- package/lib/screenplay/questions/index.js.map +1 -1
- package/lib/stage/crew/photographer/Photographer.js +4 -2
- package/lib/stage/crew/photographer/Photographer.js.map +1 -1
- package/package.json +12 -11
- package/src/screenplay/questions/Attribute.ts +11 -11
- package/src/screenplay/questions/ComputedStyle.ts +206 -0
- package/src/screenplay/questions/index.ts +1 -0
- package/src/stage/crew/photographer/Photographer.ts +2 -2
- package/tsconfig.build.json +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComputedStyle = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
/**
|
|
8
|
+
* Uses the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
9
|
+
* the value of the specified computed style property of a given {@apilink PageElement}.
|
|
10
|
+
*
|
|
11
|
+
* ## Example widget
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <ul id="shopping-list" style="display: block">
|
|
15
|
+
* <li style="display: block">Coffee<li>
|
|
16
|
+
* <li style="display: none">Honey<li>
|
|
17
|
+
* <li style="display: block">Chocolate<li>
|
|
18
|
+
* </ul>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## Retrieve a computed style property of a given {@apilink PageElement}
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
25
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
26
|
+
* import { ComputedStyle, By, PageElement } from '@serenity-js/web'
|
|
27
|
+
*
|
|
28
|
+
* const shoppingList = () =>
|
|
29
|
+
* PageElement.located(By.id('shopping-list'))
|
|
30
|
+
* .describedAs('shopping list')
|
|
31
|
+
*
|
|
32
|
+
* await actorCalled('Lisa').attemptsTo(
|
|
33
|
+
* Ensure.that(
|
|
34
|
+
* ComputedStyle.called('display').of(shoppingList()),
|
|
35
|
+
* equals('block')
|
|
36
|
+
* ),
|
|
37
|
+
* )
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* ## Using `ComputedStyle` as {@apilink QuestionAdapter}
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
44
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
45
|
+
* import { Attribute, By, PageElement } from '@serenity-js/web'
|
|
46
|
+
*
|
|
47
|
+
* const shoppingList = () =>
|
|
48
|
+
* PageElement.located(By.css('#shopping-list'))
|
|
49
|
+
* .describedAs('shopping list')
|
|
50
|
+
*
|
|
51
|
+
* await actorCalled('Lisa').attemptsTo(
|
|
52
|
+
* Ensure.that(
|
|
53
|
+
* ComputedStyle.called('display').of(shoppingList()).toLocaleUpperCase(),
|
|
54
|
+
* equals('BLOCK')
|
|
55
|
+
* ),
|
|
56
|
+
* )
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* ## Using as filter in {@apilink PageElements|Page Element Query Language}
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
63
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
64
|
+
* import { Attribute, By, PageElements } from '@serenity-js/web'
|
|
65
|
+
*
|
|
66
|
+
* class ShoppingList {
|
|
67
|
+
* static items = () =>
|
|
68
|
+
* PageElements.located(By.css('#shopping-list li'))
|
|
69
|
+
* .describedAs('items')
|
|
70
|
+
*
|
|
71
|
+
* static outstandingItems = () =>
|
|
72
|
+
* ShoppingList.items()
|
|
73
|
+
* .where(
|
|
74
|
+
* ComputedStyle.called('display'),
|
|
75
|
+
* equals('block')
|
|
76
|
+
* )
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* await actorCalled('Lisa')
|
|
80
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
81
|
+
* .attemptsTo(
|
|
82
|
+
* Ensure.that(
|
|
83
|
+
* Text.ofAll(ShoppingList.outstandingItems()),
|
|
84
|
+
* equals([ 'Honey', 'Chocolate' ])
|
|
85
|
+
* ),
|
|
86
|
+
* )
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* ## Learn more
|
|
90
|
+
* - {@apilink BrowseTheWeb}
|
|
91
|
+
* - {@apilink MetaQuestion}
|
|
92
|
+
* - {@apilink QuestionAdapter}
|
|
93
|
+
* - {@apilink Question}
|
|
94
|
+
*
|
|
95
|
+
* @group Questions
|
|
96
|
+
*/
|
|
97
|
+
class ComputedStyle extends core_1.Question {
|
|
98
|
+
name;
|
|
99
|
+
element;
|
|
100
|
+
pseudoElement;
|
|
101
|
+
subject;
|
|
102
|
+
/**
|
|
103
|
+
* Instantiates a {@apilink Question} that uses
|
|
104
|
+
* the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
105
|
+
* the value of the specified computed style property of a given {@apilink PageElement}.
|
|
106
|
+
*
|
|
107
|
+
* @param name
|
|
108
|
+
* The name of the computed style property to retrieve
|
|
109
|
+
*/
|
|
110
|
+
static called(name) {
|
|
111
|
+
return new ComputedStyle(name);
|
|
112
|
+
}
|
|
113
|
+
constructor(name, element, pseudoElement) {
|
|
114
|
+
super();
|
|
115
|
+
this.name = name;
|
|
116
|
+
this.element = element;
|
|
117
|
+
this.pseudoElement = pseudoElement;
|
|
118
|
+
this.subject = [
|
|
119
|
+
(0, core_1.d) `computed style property ${name}`,
|
|
120
|
+
pseudoElement && (0, core_1.d) `of pseudo-element ${pseudoElement}`,
|
|
121
|
+
element && (0, core_1.d) `of ${element}`,
|
|
122
|
+
].filter(Boolean).join(' ');
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Instantiates a {@apilink Question} that uses
|
|
126
|
+
* the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
127
|
+
* the value of the specified computed style property of the specified pseudo-element of a given {@apilink PageElement}.
|
|
128
|
+
*
|
|
129
|
+
* @param pseudoElement
|
|
130
|
+
* The pseudo-element to retrieve the computed style property from, such as `::before` or `::after`
|
|
131
|
+
*/
|
|
132
|
+
ofPseudoElement(pseudoElement) {
|
|
133
|
+
return core_1.Question.createAdapter(new ComputedStyle(this.name, this.element, pseudoElement));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Resolves to the value of a computed style property of the `pageElement`.
|
|
137
|
+
*
|
|
138
|
+
* #### Learn more
|
|
139
|
+
* - {@apilink MetaQuestion}
|
|
140
|
+
*
|
|
141
|
+
* @param pageElement
|
|
142
|
+
*/
|
|
143
|
+
of(pageElement) {
|
|
144
|
+
return core_1.Question.createAdapter(new ComputedStyle(this.name, this.element
|
|
145
|
+
? models_1.PageElement.of(this.element, pageElement)
|
|
146
|
+
: pageElement, this.pseudoElement));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @inheritDoc
|
|
150
|
+
*/
|
|
151
|
+
async answeredBy(actor) {
|
|
152
|
+
const name = await actor.answer(this.name);
|
|
153
|
+
if (!this.element) {
|
|
154
|
+
throw new core_1.LogicError((0, core_1.d) `Couldn't read computed style property ${name} of an unspecified page element`);
|
|
155
|
+
}
|
|
156
|
+
const element = await actor.answer(this.element);
|
|
157
|
+
const pseudoElement = await actor.answer(this.pseudoElement);
|
|
158
|
+
const page = await abilities_1.BrowseTheWeb.as(actor).currentPage();
|
|
159
|
+
return page.executeScript('return window.getComputedStyle(arguments[0], arguments[1]).getPropertyValue(arguments[2])', element, pseudoElement, name);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @inheritDoc
|
|
163
|
+
*/
|
|
164
|
+
describedAs(subject) {
|
|
165
|
+
this.subject = subject;
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @inheritDoc
|
|
170
|
+
*/
|
|
171
|
+
toString() {
|
|
172
|
+
return this.subject;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.ComputedStyle = ComputedStyle;
|
|
176
|
+
//# sourceMappingURL=ComputedStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComputedStyle.js","sourceRoot":"","sources":["../../../src/screenplay/questions/ComputedStyle.ts"],"names":[],"mappings":";;;AAQA,4CAA4D;AAE5D,4CAA4C;AAC5C,sCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,MAAa,aACT,SAAQ,eAAyB;IAkBZ;IACA;IACA;IAjBb,OAAO,CAAS;IAExB;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAY,IAAwB;QAC7C,OAAO,IAAI,aAAa,CAAM,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,YACqB,IAAwB,EACxB,OAA8F,EAC9F,aAAkC;QAEnD,KAAK,EAAE,CAAC;QAJS,SAAI,GAAJ,IAAI,CAAoB;QACxB,YAAO,GAAP,OAAO,CAAuF;QAC9F,kBAAa,GAAb,aAAa,CAAqB;QAInD,IAAI,CAAC,OAAO,GAAG;YACX,IAAA,QAAC,EAAA,2BAA4B,IAAK,EAAE;YACpC,aAAa,IAAI,IAAA,QAAC,EAAA,qBAAsB,aAAc,EAAE;YACxD,OAAO,IAAI,IAAA,QAAC,EAAA,MAAO,OAAQ,EAAE;SAChC,CAAC,MAAM,CAAC,OAAO,CAAC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AAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAtGD,sCAsGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Attribute"), exports);
|
|
18
|
+
__exportStar(require("./ComputedStyle"), exports);
|
|
18
19
|
__exportStar(require("./CssClasses"), exports);
|
|
19
20
|
__exportStar(require("./LastScriptExecution"), exports);
|
|
20
21
|
__exportStar(require("./Selected"), exports);
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,kDAAgC;AAChC,+CAA6B;AAC7B,wDAAsC;AACtC,6CAA2B;AAC3B,yCAAuB;AACvB,0CAAwB"}
|
|
@@ -175,6 +175,8 @@ const strategies = __importStar(require("./strategies"));
|
|
|
175
175
|
* @group Stage
|
|
176
176
|
*/
|
|
177
177
|
class Photographer {
|
|
178
|
+
photoTakingStrategy;
|
|
179
|
+
stage;
|
|
178
180
|
/**
|
|
179
181
|
* Instantiates a new {@apilink Photographer} configured to take photos (screenshots)
|
|
180
182
|
* as per the specified {@apilink PhotoTakingStrategy}.
|
|
@@ -197,8 +199,8 @@ class Photographer {
|
|
|
197
199
|
if (availableStrategies.includes(config.strategy)) {
|
|
198
200
|
return new Photographer(new strategies[config.strategy]());
|
|
199
201
|
}
|
|
200
|
-
throw new core_1.ConfigurationError(`'${config.strategy}' is not an available PhotoTakingStrategy
|
|
201
|
-
`
|
|
202
|
+
throw new core_1.ConfigurationError(`'${config.strategy}' is not an available PhotoTakingStrategy, ` +
|
|
203
|
+
`available strategies: ${availableStrategies.join(', ')}.`);
|
|
202
204
|
}
|
|
203
205
|
return new Photographer(new strategies.TakePhotosOfFailures());
|
|
204
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Photographer.js","sourceRoot":"","sources":["../../../../src/stage/crew/photographer/Photographer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAmE;AAEnE,yDAAgF;AAGhF,yDAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkJG;AACH,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"Photographer.js","sourceRoot":"","sources":["../../../../src/st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K,CAAQ;IAEzB,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,KAAY;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,KAAkB;QACvB,IAAI,CAAE,IAAI,CAAC,KAAK,EAAE;YACd,MAAM,IAAI,iBAAU,CAAC,8FAA8F,CAAC,CAAC;SACxH;QAED,IAAI,CAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE;YAClC,OAAO,KAAK,CAAC,CAAC;SACjB;QAED,IAAI,KAAK,YAAY,uBAAc,IAAI,KAAK,YAAY,yBAAgB,EAAE;YACtE,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;SACnE;IACL,CAAC;CACJ;AAxED,oCAwEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/web",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern APIs for the Web",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"homepage": "https://serenity-js.org",
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
16
|
+
"access": "public",
|
|
17
|
+
"provenance": true
|
|
17
18
|
},
|
|
18
19
|
"main": "lib/index.js",
|
|
19
20
|
"types": "./lib/index.d.ts",
|
|
@@ -44,19 +45,19 @@
|
|
|
44
45
|
"node": "^16.13 || ^18.12 || ^20"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@serenity-js/assertions": "3.
|
|
48
|
-
"@serenity-js/core": "3.
|
|
49
|
-
"tiny-types": "
|
|
48
|
+
"@serenity-js/assertions": "3.14.1",
|
|
49
|
+
"@serenity-js/core": "3.14.1",
|
|
50
|
+
"tiny-types": "1.21.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@integration/testing-tools": "3.0.0",
|
|
53
|
-
"@types/chai": "
|
|
54
|
-
"@types/mocha": "
|
|
54
|
+
"@types/chai": "4.3.11",
|
|
55
|
+
"@types/mocha": "10.0.6",
|
|
55
56
|
"c8": "8.0.1",
|
|
56
|
-
"mocha": "
|
|
57
|
-
"mocha-multi": "
|
|
58
|
-
"ts-node": "
|
|
57
|
+
"mocha": "10.2.0",
|
|
58
|
+
"mocha-multi": "1.1.7",
|
|
59
|
+
"ts-node": "10.9.2",
|
|
59
60
|
"typescript": "5.1.6"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "27c466fdd19ebeb766b8517c847f1163e8ed8d6f"
|
|
62
63
|
}
|
|
@@ -20,13 +20,13 @@ import { PageElement } from '../models';
|
|
|
20
20
|
* ## Retrieve an HTML attribute of a given {@apilink PageElement}
|
|
21
21
|
*
|
|
22
22
|
* ```ts
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
24
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
25
|
+
* import { Attribute, By, PageElement } from '@serenity-js/web'
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* const shoppingList = () =>
|
|
28
|
+
* PageElement.located(By.id('shopping-list'))
|
|
29
|
+
* .describedAs('shopping list')
|
|
30
30
|
*
|
|
31
31
|
* await actorCalled('Lisa')
|
|
32
32
|
* .attemptsTo(
|
|
@@ -95,9 +95,9 @@ import { PageElement } from '../models';
|
|
|
95
95
|
*
|
|
96
96
|
* @group Questions
|
|
97
97
|
*/
|
|
98
|
-
export class Attribute
|
|
98
|
+
export class Attribute<Native_Element_Type>
|
|
99
99
|
extends Question<Promise<string>>
|
|
100
|
-
implements MetaQuestion<PageElement
|
|
100
|
+
implements MetaQuestion<PageElement<Native_Element_Type>, Question<Promise<string>>>
|
|
101
101
|
{
|
|
102
102
|
private subject: string;
|
|
103
103
|
|
|
@@ -109,7 +109,7 @@ export class Attribute
|
|
|
109
109
|
* @param name
|
|
110
110
|
* The name of the attribute to retrieve
|
|
111
111
|
*/
|
|
112
|
-
static called(name: Answerable<string>): Attribute {
|
|
112
|
+
static called<NET = any>(name: Answerable<string>): Attribute<NET> {
|
|
113
113
|
return new Attribute(name);
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -131,7 +131,7 @@ export class Attribute
|
|
|
131
131
|
*
|
|
132
132
|
* @param pageElement
|
|
133
133
|
*/
|
|
134
|
-
of(pageElement: QuestionAdapter<PageElement
|
|
134
|
+
of(pageElement: QuestionAdapter<PageElement<Native_Element_Type>> | PageElement<Native_Element_Type>): MetaQuestionAdapter<PageElement<Native_Element_Type>, string> {
|
|
135
135
|
return Question.createAdapter(
|
|
136
136
|
new Attribute(
|
|
137
137
|
this.name,
|
|
@@ -149,7 +149,7 @@ export class Attribute
|
|
|
149
149
|
const name = await actor.answer(this.name);
|
|
150
150
|
|
|
151
151
|
if (! this.element) {
|
|
152
|
-
throw new LogicError(d`Couldn't read attribute ${ name } of an unspecified page element
|
|
152
|
+
throw new LogicError(d`Couldn't read attribute ${ name } of an unspecified page element`);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
const element = await actor.answer(this.element);
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Answerable,
|
|
3
|
+
AnswersQuestions,
|
|
4
|
+
MetaQuestion,
|
|
5
|
+
MetaQuestionAdapter,
|
|
6
|
+
QuestionAdapter,
|
|
7
|
+
UsesAbilities
|
|
8
|
+
} from '@serenity-js/core';
|
|
9
|
+
import { d, LogicError, Question } from '@serenity-js/core';
|
|
10
|
+
|
|
11
|
+
import { BrowseTheWeb } from '../abilities';
|
|
12
|
+
import { PageElement } from '../models';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Uses the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
16
|
+
* the value of the specified computed style property of a given {@apilink PageElement}.
|
|
17
|
+
*
|
|
18
|
+
* ## Example widget
|
|
19
|
+
*
|
|
20
|
+
* ```html
|
|
21
|
+
* <ul id="shopping-list" style="display: block">
|
|
22
|
+
* <li style="display: block">Coffee<li>
|
|
23
|
+
* <li style="display: none">Honey<li>
|
|
24
|
+
* <li style="display: block">Chocolate<li>
|
|
25
|
+
* </ul>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Retrieve a computed style property of a given {@apilink PageElement}
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
32
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
33
|
+
* import { ComputedStyle, By, PageElement } from '@serenity-js/web'
|
|
34
|
+
*
|
|
35
|
+
* const shoppingList = () =>
|
|
36
|
+
* PageElement.located(By.id('shopping-list'))
|
|
37
|
+
* .describedAs('shopping list')
|
|
38
|
+
*
|
|
39
|
+
* await actorCalled('Lisa').attemptsTo(
|
|
40
|
+
* Ensure.that(
|
|
41
|
+
* ComputedStyle.called('display').of(shoppingList()),
|
|
42
|
+
* equals('block')
|
|
43
|
+
* ),
|
|
44
|
+
* )
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## Using `ComputedStyle` as {@apilink QuestionAdapter}
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
51
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
52
|
+
* import { Attribute, By, PageElement } from '@serenity-js/web'
|
|
53
|
+
*
|
|
54
|
+
* const shoppingList = () =>
|
|
55
|
+
* PageElement.located(By.css('#shopping-list'))
|
|
56
|
+
* .describedAs('shopping list')
|
|
57
|
+
*
|
|
58
|
+
* await actorCalled('Lisa').attemptsTo(
|
|
59
|
+
* Ensure.that(
|
|
60
|
+
* ComputedStyle.called('display').of(shoppingList()).toLocaleUpperCase(),
|
|
61
|
+
* equals('BLOCK')
|
|
62
|
+
* ),
|
|
63
|
+
* )
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* ## Using as filter in {@apilink PageElements|Page Element Query Language}
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
70
|
+
* import { Ensure, includes } from '@serenity-js/assertions'
|
|
71
|
+
* import { Attribute, By, PageElements } from '@serenity-js/web'
|
|
72
|
+
*
|
|
73
|
+
* class ShoppingList {
|
|
74
|
+
* static items = () =>
|
|
75
|
+
* PageElements.located(By.css('#shopping-list li'))
|
|
76
|
+
* .describedAs('items')
|
|
77
|
+
*
|
|
78
|
+
* static outstandingItems = () =>
|
|
79
|
+
* ShoppingList.items()
|
|
80
|
+
* .where(
|
|
81
|
+
* ComputedStyle.called('display'),
|
|
82
|
+
* equals('block')
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* await actorCalled('Lisa')
|
|
87
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
88
|
+
* .attemptsTo(
|
|
89
|
+
* Ensure.that(
|
|
90
|
+
* Text.ofAll(ShoppingList.outstandingItems()),
|
|
91
|
+
* equals([ 'Honey', 'Chocolate' ])
|
|
92
|
+
* ),
|
|
93
|
+
* )
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* ## Learn more
|
|
97
|
+
* - {@apilink BrowseTheWeb}
|
|
98
|
+
* - {@apilink MetaQuestion}
|
|
99
|
+
* - {@apilink QuestionAdapter}
|
|
100
|
+
* - {@apilink Question}
|
|
101
|
+
*
|
|
102
|
+
* @group Questions
|
|
103
|
+
*/
|
|
104
|
+
export class ComputedStyle<Native_Element_Type>
|
|
105
|
+
extends Question<Promise<string>>
|
|
106
|
+
implements MetaQuestion<PageElement<Native_Element_Type>, Question<Promise<string>>>
|
|
107
|
+
{
|
|
108
|
+
private subject: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Instantiates a {@apilink Question} that uses
|
|
112
|
+
* the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
113
|
+
* the value of the specified computed style property of a given {@apilink PageElement}.
|
|
114
|
+
*
|
|
115
|
+
* @param name
|
|
116
|
+
* The name of the computed style property to retrieve
|
|
117
|
+
*/
|
|
118
|
+
static called<NET = any>(name: Answerable<string>): ComputedStyle<NET> {
|
|
119
|
+
return new ComputedStyle<NET>(name);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected constructor(
|
|
123
|
+
private readonly name: Answerable<string>,
|
|
124
|
+
private readonly element?: QuestionAdapter<PageElement<Native_Element_Type>> | PageElement<Native_Element_Type>,
|
|
125
|
+
private readonly pseudoElement?: Answerable<string>,
|
|
126
|
+
) {
|
|
127
|
+
super();
|
|
128
|
+
|
|
129
|
+
this.subject = [
|
|
130
|
+
d`computed style property ${ name }`,
|
|
131
|
+
pseudoElement && d`of pseudo-element ${ pseudoElement }`,
|
|
132
|
+
element && d`of ${ element }`,
|
|
133
|
+
].filter(Boolean).join(' ');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Instantiates a {@apilink Question} that uses
|
|
138
|
+
* the {@apilink Actor|actor's} {@apilink Ability|ability} to {@apilink BrowseTheWeb} to retrieve
|
|
139
|
+
* the value of the specified computed style property of the specified pseudo-element of a given {@apilink PageElement}.
|
|
140
|
+
*
|
|
141
|
+
* @param pseudoElement
|
|
142
|
+
* The pseudo-element to retrieve the computed style property from, such as `::before` or `::after`
|
|
143
|
+
*/
|
|
144
|
+
ofPseudoElement(pseudoElement: Answerable<string>): MetaQuestionAdapter<PageElement<Native_Element_Type>, string> {
|
|
145
|
+
return Question.createAdapter(
|
|
146
|
+
new ComputedStyle<Native_Element_Type>(
|
|
147
|
+
this.name,
|
|
148
|
+
this.element,
|
|
149
|
+
pseudoElement,
|
|
150
|
+
)
|
|
151
|
+
) as MetaQuestionAdapter<PageElement<Native_Element_Type>, string>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Resolves to the value of a computed style property of the `pageElement`.
|
|
156
|
+
*
|
|
157
|
+
* #### Learn more
|
|
158
|
+
* - {@apilink MetaQuestion}
|
|
159
|
+
*
|
|
160
|
+
* @param pageElement
|
|
161
|
+
*/
|
|
162
|
+
of(pageElement: QuestionAdapter<PageElement<Native_Element_Type>> | PageElement<Native_Element_Type>): MetaQuestionAdapter<PageElement<Native_Element_Type>, string> {
|
|
163
|
+
return Question.createAdapter(
|
|
164
|
+
new ComputedStyle<Native_Element_Type>(
|
|
165
|
+
this.name,
|
|
166
|
+
this.element
|
|
167
|
+
? PageElement.of(this.element, pageElement)
|
|
168
|
+
: pageElement,
|
|
169
|
+
this.pseudoElement,
|
|
170
|
+
)
|
|
171
|
+
) as MetaQuestionAdapter<PageElement<Native_Element_Type>, string>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @inheritDoc
|
|
176
|
+
*/
|
|
177
|
+
async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string> {
|
|
178
|
+
const name = await actor.answer(this.name);
|
|
179
|
+
|
|
180
|
+
if (! this.element) {
|
|
181
|
+
throw new LogicError(d`Couldn't read computed style property ${ name } of an unspecified page element`);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const element = await actor.answer(this.element);
|
|
185
|
+
const pseudoElement = await actor.answer(this.pseudoElement);
|
|
186
|
+
|
|
187
|
+
const page = await BrowseTheWeb.as(actor).currentPage();
|
|
188
|
+
|
|
189
|
+
return page.executeScript('return window.getComputedStyle(arguments[0], arguments[1]).getPropertyValue(arguments[2])', element, pseudoElement, name);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @inheritDoc
|
|
194
|
+
*/
|
|
195
|
+
describedAs(subject: string): this {
|
|
196
|
+
this.subject = subject;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @inheritDoc
|
|
202
|
+
*/
|
|
203
|
+
toString(): string {
|
|
204
|
+
return this.subject;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -180,8 +180,8 @@ export class Photographer implements StageCrewMember {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
throw new ConfigurationError(
|
|
183
|
-
`'${ config.strategy }' is not an available PhotoTakingStrategy
|
|
184
|
-
`
|
|
183
|
+
`'${ config.strategy }' is not an available PhotoTakingStrategy, ` +
|
|
184
|
+
`available strategies: ${ availableStrategies.join(', ') }.`
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
|