@serenity-js/webdriverio 2.32.2 → 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 +73 -0
- package/lib/adapter/WebdriverIOFrameworkAdapter.js +1 -1
- package/lib/adapter/WebdriverIOFrameworkAdapter.js.map +1 -1
- package/lib/adapter/WebdriverIONotifier.d.ts +35 -1
- package/lib/adapter/WebdriverIONotifier.js +174 -13
- package/lib/adapter/WebdriverIONotifier.js.map +1 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/{BrowseTheWeb.d.ts → BrowseTheWebWithWebdriverIO.d.ts} +79 -23
- package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithWebdriverIO.js} +160 -25
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -2
- package/lib/screenplay/index.js +1 -2
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOCookie.d.ts +8 -0
- package/lib/screenplay/models/WebdriverIOCookie.js +39 -0
- package/lib/screenplay/models/WebdriverIOCookie.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.d.ts +11 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js +40 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js.map +1 -0
- package/lib/screenplay/models/WebdriverIONativeElementRoot.d.ts +2 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/WebdriverIONativeElementRoot.js} +1 -1
- package/lib/screenplay/models/WebdriverIONativeElementRoot.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPage.d.ts +24 -0
- package/lib/screenplay/models/WebdriverIOPage.js +98 -0
- package/lib/screenplay/models/WebdriverIOPage.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElement.d.ts +22 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js +75 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElements.d.ts +15 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js +65 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +6 -0
- package/lib/{input → screenplay/models}/index.js +6 -1
- package/lib/screenplay/models/index.js.map +1 -0
- package/package.json +22 -32
- package/src/adapter/WebdriverIOFrameworkAdapter.ts +2 -0
- package/src/adapter/WebdriverIONotifier.ts +225 -23
- package/src/index.ts +0 -3
- package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithWebdriverIO.ts} +200 -31
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +1 -2
- package/src/screenplay/models/WebdriverIOCookie.ts +44 -0
- package/src/screenplay/models/WebdriverIOModalDialog.ts +45 -0
- package/src/screenplay/models/WebdriverIONativeElementRoot.ts +3 -0
- package/src/screenplay/models/WebdriverIOPage.ts +120 -0
- package/src/screenplay/models/WebdriverIOPageElement.ts +92 -0
- package/src/screenplay/models/WebdriverIOPageElements.ts +91 -0
- package/src/screenplay/models/index.ts +6 -0
- package/lib/expectations/ElementExpectation.d.ts +0 -11
- package/lib/expectations/ElementExpectation.js +0 -27
- package/lib/expectations/ElementExpectation.js.map +0 -1
- package/lib/expectations/index.d.ts +0 -6
- package/lib/expectations/index.js +0 -19
- package/lib/expectations/index.js.map +0 -1
- package/lib/expectations/isActive.d.ts +0 -15
- package/lib/expectations/isActive.js +0 -21
- package/lib/expectations/isActive.js.map +0 -1
- package/lib/expectations/isClickable.d.ts +0 -20
- package/lib/expectations/isClickable.js +0 -26
- package/lib/expectations/isClickable.js.map +0 -1
- package/lib/expectations/isEnabled.d.ts +0 -14
- package/lib/expectations/isEnabled.js +0 -20
- package/lib/expectations/isEnabled.js.map +0 -1
- package/lib/expectations/isPresent.d.ts +0 -15
- package/lib/expectations/isPresent.js +0 -21
- package/lib/expectations/isPresent.js.map +0 -1
- package/lib/expectations/isSelected.d.ts +0 -14
- package/lib/expectations/isSelected.js +0 -20
- package/lib/expectations/isSelected.js.map +0 -1
- package/lib/expectations/isVisible.d.ts +0 -14
- package/lib/expectations/isVisible.js +0 -20
- package/lib/expectations/isVisible.js.map +0 -1
- package/lib/input/Key.d.ts +0 -73
- package/lib/input/Key.js +0 -84
- package/lib/input/Key.js.map +0 -1
- package/lib/input/index.d.ts +0 -1
- package/lib/input/index.js.map +0 -1
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +0 -1
- package/lib/screenplay/interactions/Clear.d.ts +0 -79
- package/lib/screenplay/interactions/Clear.js +0 -97
- package/lib/screenplay/interactions/Clear.js.map +0 -1
- package/lib/screenplay/interactions/Click.d.ts +0 -73
- package/lib/screenplay/interactions/Click.js +0 -84
- package/lib/screenplay/interactions/Click.js.map +0 -1
- package/lib/screenplay/interactions/DoubleClick.d.ts +0 -90
- package/lib/screenplay/interactions/DoubleClick.js +0 -101
- package/lib/screenplay/interactions/DoubleClick.js.map +0 -1
- package/lib/screenplay/interactions/Enter.d.ts +0 -73
- package/lib/screenplay/interactions/Enter.js +0 -87
- package/lib/screenplay/interactions/Enter.js.map +0 -1
- package/lib/screenplay/interactions/EnterBuilder.d.ts +0 -25
- package/lib/screenplay/interactions/EnterBuilder.js.map +0 -1
- package/lib/screenplay/interactions/ExecuteScript.d.ts +0 -206
- package/lib/screenplay/interactions/ExecuteScript.js +0 -311
- package/lib/screenplay/interactions/ExecuteScript.js.map +0 -1
- package/lib/screenplay/interactions/Hover.d.ts +0 -78
- package/lib/screenplay/interactions/Hover.js +0 -89
- package/lib/screenplay/interactions/Hover.js.map +0 -1
- package/lib/screenplay/interactions/Navigate.d.ts +0 -141
- package/lib/screenplay/interactions/Navigate.js +0 -197
- package/lib/screenplay/interactions/Navigate.js.map +0 -1
- package/lib/screenplay/interactions/Press.d.ts +0 -84
- package/lib/screenplay/interactions/Press.js +0 -152
- package/lib/screenplay/interactions/Press.js.map +0 -1
- package/lib/screenplay/interactions/PressBuilder.d.ts +0 -26
- package/lib/screenplay/interactions/PressBuilder.js +0 -3
- package/lib/screenplay/interactions/PressBuilder.js.map +0 -1
- package/lib/screenplay/interactions/RightClick.d.ts +0 -89
- package/lib/screenplay/interactions/RightClick.js +0 -100
- package/lib/screenplay/interactions/RightClick.js.map +0 -1
- package/lib/screenplay/interactions/Scroll.d.ts +0 -75
- package/lib/screenplay/interactions/Scroll.js +0 -86
- package/lib/screenplay/interactions/Scroll.js.map +0 -1
- package/lib/screenplay/interactions/Wait.d.ts +0 -143
- package/lib/screenplay/interactions/Wait.js +0 -247
- package/lib/screenplay/interactions/Wait.js.map +0 -1
- package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -32
- package/lib/screenplay/interactions/WaitBuilder.js +0 -3
- package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
- package/lib/screenplay/interactions/WebElementInteraction.d.ts +0 -37
- package/lib/screenplay/interactions/WebElementInteraction.js +0 -52
- package/lib/screenplay/interactions/WebElementInteraction.js.map +0 -1
- package/lib/screenplay/interactions/index.d.ts +0 -13
- package/lib/screenplay/interactions/index.js +0 -26
- package/lib/screenplay/interactions/index.js.map +0 -1
- package/lib/screenplay/questions/Attribute.d.ts +0 -82
- package/lib/screenplay/questions/Attribute.js +0 -102
- package/lib/screenplay/questions/Attribute.js.map +0 -1
- package/lib/screenplay/questions/CSSClasses.d.ts +0 -92
- package/lib/screenplay/questions/CSSClasses.js +0 -112
- package/lib/screenplay/questions/CSSClasses.js.map +0 -1
- package/lib/screenplay/questions/LastScriptExecution.d.ts +0 -14
- package/lib/screenplay/questions/LastScriptExecution.js +0 -22
- package/lib/screenplay/questions/LastScriptExecution.js.map +0 -1
- package/lib/screenplay/questions/NestedTargetBuilder.d.ts +0 -27
- package/lib/screenplay/questions/NestedTargetBuilder.js +0 -3
- package/lib/screenplay/questions/NestedTargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/TargetBuilder.d.ts +0 -25
- package/lib/screenplay/questions/TargetBuilder.js +0 -3
- package/lib/screenplay/questions/TargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/Text.d.ts +0 -95
- package/lib/screenplay/questions/Text.js +0 -130
- package/lib/screenplay/questions/Text.js.map +0 -1
- package/lib/screenplay/questions/Value.d.ts +0 -63
- package/lib/screenplay/questions/Value.js +0 -78
- package/lib/screenplay/questions/Value.js.map +0 -1
- package/lib/screenplay/questions/Website.d.ts +0 -21
- package/lib/screenplay/questions/Website.js +0 -31
- package/lib/screenplay/questions/Website.js.map +0 -1
- package/lib/screenplay/questions/index.d.ts +0 -10
- package/lib/screenplay/questions/index.js +0 -23
- package/lib/screenplay/questions/index.js.map +0 -1
- package/lib/screenplay/questions/lists.d.ts +0 -86
- package/lib/screenplay/questions/lists.js +0 -137
- package/lib/screenplay/questions/lists.js.map +0 -1
- package/lib/screenplay/questions/locators.d.ts +0 -196
- package/lib/screenplay/questions/locators.js +0 -219
- package/lib/screenplay/questions/locators.js.map +0 -1
- package/lib/screenplay/questions/targets.d.ts +0 -254
- package/lib/screenplay/questions/targets.js +0 -334
- package/lib/screenplay/questions/targets.js.map +0 -1
- package/lib/stage/crew/index.d.ts +0 -1
- package/lib/stage/crew/index.js +0 -14
- package/lib/stage/crew/index.js.map +0 -1
- package/lib/stage/crew/photographer/Photographer.d.ts +0 -83
- package/lib/stage/crew/photographer/Photographer.js +0 -102
- package/lib/stage/crew/photographer/Photographer.js.map +0 -1
- package/lib/stage/crew/photographer/index.d.ts +0 -2
- package/lib/stage/crew/photographer/index.js +0 -15
- package/lib/stage/crew/photographer/index.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +0 -28
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +0 -65
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +0 -18
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +0 -30
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +0 -17
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +0 -19
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/index.d.ts +0 -4
- package/lib/stage/crew/photographer/strategies/index.js +0 -17
- package/lib/stage/crew/photographer/strategies/index.js.map +0 -1
- package/lib/stage/index.d.ts +0 -1
- package/lib/stage/index.js +0 -14
- package/lib/stage/index.js.map +0 -1
- package/src/expectations/ElementExpectation.ts +0 -31
- package/src/expectations/index.ts +0 -6
- package/src/expectations/isActive.ts +0 -21
- package/src/expectations/isClickable.ts +0 -26
- package/src/expectations/isEnabled.ts +0 -19
- package/src/expectations/isPresent.ts +0 -20
- package/src/expectations/isSelected.ts +0 -19
- package/src/expectations/isVisible.ts +0 -19
- package/src/input/Key.ts +0 -83
- package/src/input/index.ts +0 -1
- package/src/screenplay/interactions/Clear.ts +0 -102
- package/src/screenplay/interactions/Click.ts +0 -85
- package/src/screenplay/interactions/DoubleClick.ts +0 -102
- package/src/screenplay/interactions/Enter.ts +0 -93
- package/src/screenplay/interactions/EnterBuilder.ts +0 -27
- package/src/screenplay/interactions/ExecuteScript.ts +0 -344
- package/src/screenplay/interactions/Hover.ts +0 -90
- package/src/screenplay/interactions/Navigate.ts +0 -208
- package/src/screenplay/interactions/Press.ts +0 -172
- package/src/screenplay/interactions/PressBuilder.ts +0 -28
- package/src/screenplay/interactions/RightClick.ts +0 -100
- package/src/screenplay/interactions/Scroll.ts +0 -87
- package/src/screenplay/interactions/Wait.ts +0 -267
- package/src/screenplay/interactions/WaitBuilder.ts +0 -34
- package/src/screenplay/interactions/WebElementInteraction.ts +0 -56
- package/src/screenplay/interactions/index.ts +0 -13
- package/src/screenplay/questions/Attribute.ts +0 -112
- package/src/screenplay/questions/CSSClasses.ts +0 -116
- package/src/screenplay/questions/LastScriptExecution.ts +0 -21
- package/src/screenplay/questions/NestedTargetBuilder.ts +0 -30
- package/src/screenplay/questions/TargetBuilder.ts +0 -27
- package/src/screenplay/questions/Text.ts +0 -140
- package/src/screenplay/questions/Value.ts +0 -82
- package/src/screenplay/questions/Website.ts +0 -34
- package/src/screenplay/questions/index.ts +0 -10
- package/src/screenplay/questions/lists.ts +0 -161
- package/src/screenplay/questions/locators.ts +0 -254
- package/src/screenplay/questions/targets.ts +0 -401
- package/src/stage/crew/index.ts +0 -1
- package/src/stage/crew/photographer/Photographer.ts +0 -108
- package/src/stage/crew/photographer/index.ts +0 -2
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +0 -103
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +0 -28
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +0 -26
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +0 -26
- package/src/stage/crew/photographer/strategies/index.ts +0 -4
- package/src/stage/index.ts +0 -1
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TargetNestedElement = exports.TargetElement = exports.TargetNestedElements = exports.TargetElements = exports.Target = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
5
|
-
const core_1 = require("@serenity-js/core");
|
|
6
|
-
const io_1 = require("@serenity-js/core/lib/io");
|
|
7
|
-
const lists_1 = require("./lists");
|
|
8
|
-
/**
|
|
9
|
-
* @desc
|
|
10
|
-
* Provides a convenient way to retrieve a single web element or multiple web elements,
|
|
11
|
-
* so that they can be used with Serenity/JS {@link @serenity-js/core/lib/screenplay~Interaction}s.
|
|
12
|
-
*
|
|
13
|
-
* Check out the examples below, as well as the unit tests demonstrating the usage.
|
|
14
|
-
*
|
|
15
|
-
* @example <caption>Imaginary website under test</caption>
|
|
16
|
-
* <body>
|
|
17
|
-
* <ul id="basket">
|
|
18
|
-
* <li><a href="#">Apple</a></li>
|
|
19
|
-
* <li><a href="#">Banana</a></li>
|
|
20
|
-
* <li><a href="#">Coconut</a></li>
|
|
21
|
-
* <li><a href="#" class="has-discount">Date</a></li>
|
|
22
|
-
* </ul>
|
|
23
|
-
* <div id="summary">
|
|
24
|
-
* <strong class="out-of-stock">Coconut</strong> is not available
|
|
25
|
-
* </div>
|
|
26
|
-
* <button type="submit">Proceed to Checkout</button>
|
|
27
|
-
* </body>
|
|
28
|
-
*
|
|
29
|
-
* @example <caption>Locating a single element</caption>
|
|
30
|
-
* import { by, Target, TargetElement } from '@serenity-js/webdriverio';
|
|
31
|
-
*
|
|
32
|
-
* const proceedToCheckoutButton: TargetElement =
|
|
33
|
-
* Target.the('Proceed to Checkout button').located(by.css(`button[type='submit']`));
|
|
34
|
-
*
|
|
35
|
-
* @example <caption>Locating multiple elements</caption>
|
|
36
|
-
* import { by, Target, TargetElements } from '@serenity-js/webdriverio';
|
|
37
|
-
*
|
|
38
|
-
* const basketItems: TargetElements =
|
|
39
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'));
|
|
40
|
-
*
|
|
41
|
-
* @example <caption>Locating element relative to another element</caption>
|
|
42
|
-
* import { by, Target, TargetElement } from '@serenity-js/webdriverio';
|
|
43
|
-
*
|
|
44
|
-
* const summary: TargetElement =
|
|
45
|
-
* Target.the('summary').located(by.id('message'));
|
|
46
|
-
*
|
|
47
|
-
* const outOfStockItem: TargetElement =
|
|
48
|
-
* Target.the('out of stock item').of(summary).located(by.css('.out-of-stock'))
|
|
49
|
-
*
|
|
50
|
-
* @example <caption>Filtering elements matched by a locator</caption>
|
|
51
|
-
* import { by, Target, Text } from '@serenity-js/webdriverio';
|
|
52
|
-
* import { endsWith } from '@serenity-js/assertions';
|
|
53
|
-
*
|
|
54
|
-
* const basketItems =
|
|
55
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'))
|
|
56
|
-
* .where(Text, endsWith('e')); // Apple, Date
|
|
57
|
-
*
|
|
58
|
-
* @example <caption>Counting items matched by a locator</caption>
|
|
59
|
-
* import { endsWith } from '@serenity-js/assertions';
|
|
60
|
-
* import { Question } from '@serenity-js/core';
|
|
61
|
-
* import { by, Target, Text } from '@serenity-js/webdriverio';
|
|
62
|
-
*
|
|
63
|
-
* const basketItemsCount: Question<Promise<number>> =
|
|
64
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'))
|
|
65
|
-
* .count() // 4
|
|
66
|
-
*
|
|
67
|
-
* @example <caption>Getting first item matched by a locator</caption>
|
|
68
|
-
* import { Question } from '@serenity-js/core';
|
|
69
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
70
|
-
* import { Element } from 'webdriverio';
|
|
71
|
-
*
|
|
72
|
-
* const apple: Question<Promise<Element<'async'>>> =
|
|
73
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'))
|
|
74
|
-
* .first()
|
|
75
|
-
*
|
|
76
|
-
* @example <caption>Getting last item matched by a locator</caption>
|
|
77
|
-
* import { Question } from '@serenity-js/core';
|
|
78
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
79
|
-
* import { endsWith } from '@serenity-js/assertions';
|
|
80
|
-
* import { Element } from 'webdriverio';
|
|
81
|
-
*
|
|
82
|
-
* const date: Question<Promise<Element<'async'>>> =
|
|
83
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'))
|
|
84
|
-
* .last()
|
|
85
|
-
*
|
|
86
|
-
* @example <caption>Getting nth item matched by a locator</caption>
|
|
87
|
-
* import { Question } from '@serenity-js/core';
|
|
88
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
89
|
-
* import { Element } from 'webdriverio';
|
|
90
|
-
*
|
|
91
|
-
* const banana: Question<Promise<Element<'async'>>> =
|
|
92
|
-
* Target.all('items in the basket').located(by.css('ul#basket li'))
|
|
93
|
-
* .get(1)
|
|
94
|
-
*
|
|
95
|
-
* @example <caption>Using multiple filters and nested targets</caption>
|
|
96
|
-
* import { Question } from '@serenity-js/core';
|
|
97
|
-
* import { contain, endsWith } from '@serenity-js/assertions';
|
|
98
|
-
* import { by, CSSClasses, Target, Text } from '@serenity-js/webdriverio';
|
|
99
|
-
* import { Element } from 'webdriverio';
|
|
100
|
-
*
|
|
101
|
-
* class Basket {
|
|
102
|
-
* static component = Target.the('basket').located(by.id('basket'));
|
|
103
|
-
*
|
|
104
|
-
* static items = Target.all('items').located(by.css('li'))
|
|
105
|
-
* .of(Basket.component);
|
|
106
|
-
*
|
|
107
|
-
* static link = Target.the('link').located(by.css('a'));
|
|
108
|
-
* }
|
|
109
|
-
*
|
|
110
|
-
* const date: Question<Promise<Element<'async'>>> =
|
|
111
|
-
* Basket.items
|
|
112
|
-
* .where(Text, endsWith('e'))
|
|
113
|
-
* .where(CSSClasses.of(Basket.link), contain('has-discount'))
|
|
114
|
-
* .first()
|
|
115
|
-
*
|
|
116
|
-
* @example <caption>Clicking on an element</caption>
|
|
117
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
118
|
-
* import { BrowseTheWeb, Click } from '@serenity-js/webdriverio';
|
|
119
|
-
*
|
|
120
|
-
* actorCalled('Jane')
|
|
121
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
122
|
-
* .attemptsTo(
|
|
123
|
-
* Click.on(proceedToCheckoutButton),
|
|
124
|
-
* );
|
|
125
|
-
*
|
|
126
|
-
* @example <caption>Retrieving text of multiple elements and performing an assertion</caption>
|
|
127
|
-
* import { Ensure, contain } from '@serenity-js/assertions';
|
|
128
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
129
|
-
* import { BrowseTheWeb, Text } from '@serenity-js/webdriverio';
|
|
130
|
-
*
|
|
131
|
-
* const basketItemNames = Text.ofAll(basketItems);
|
|
132
|
-
*
|
|
133
|
-
* actorCalled('Jane')
|
|
134
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
135
|
-
* .attemptsTo(
|
|
136
|
-
* Ensure.that(basketItemNames, contain('Apple'))
|
|
137
|
-
* );
|
|
138
|
-
*
|
|
139
|
-
* @example <caption>Waiting on an element</caption>
|
|
140
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
141
|
-
* import { BrowseTheWeb, Wait, isClickable } from '@serenity-js/webdriverio';
|
|
142
|
-
*
|
|
143
|
-
* actorCalled('Jane')
|
|
144
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
145
|
-
* .attemptsTo(
|
|
146
|
-
* Wait.until(proceedToCheckoutButton, isClickable()),
|
|
147
|
-
* );
|
|
148
|
-
*/
|
|
149
|
-
class Target {
|
|
150
|
-
/**
|
|
151
|
-
* @desc
|
|
152
|
-
* Locates a single Web element
|
|
153
|
-
*
|
|
154
|
-
* @param {string} description
|
|
155
|
-
* A human-readable name of the element, which will be used in the report
|
|
156
|
-
*
|
|
157
|
-
* @returns {TargetBuilder<TargetElement> & NestedTargetBuilder<TargetNestedElement>}
|
|
158
|
-
*/
|
|
159
|
-
static the(description) {
|
|
160
|
-
return {
|
|
161
|
-
located(locator) {
|
|
162
|
-
return new TargetElement(`the ${description}`, locator);
|
|
163
|
-
},
|
|
164
|
-
of(parent) {
|
|
165
|
-
return {
|
|
166
|
-
located(locator) {
|
|
167
|
-
return new TargetNestedElement(parent, new TargetElement(description, locator));
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @desc
|
|
175
|
-
* Locates a group of Web elements
|
|
176
|
-
*
|
|
177
|
-
* @param {string} description
|
|
178
|
-
* A human-readable name of the group of elements, which will be used in the report
|
|
179
|
-
*
|
|
180
|
-
* @returns {TargetBuilder<TargetElements> & NestedTargetBuilder<TargetNestedElements>}
|
|
181
|
-
*/
|
|
182
|
-
static all(description) {
|
|
183
|
-
return {
|
|
184
|
-
located(locator) {
|
|
185
|
-
return new TargetElements(description, locator);
|
|
186
|
-
},
|
|
187
|
-
of(parent) {
|
|
188
|
-
return {
|
|
189
|
-
located(locator) {
|
|
190
|
-
return new TargetNestedElements(parent, new TargetElements(description, locator));
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.Target = Target;
|
|
198
|
-
/**
|
|
199
|
-
* @desc
|
|
200
|
-
* You probably don't want to use this class directly. See {@link Target} instead.
|
|
201
|
-
*
|
|
202
|
-
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
203
|
-
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
204
|
-
*
|
|
205
|
-
* @see {@link Target}
|
|
206
|
-
*/
|
|
207
|
-
class TargetElements extends core_1.Question {
|
|
208
|
-
constructor(description, locator) {
|
|
209
|
-
super(description);
|
|
210
|
-
this.locator = locator;
|
|
211
|
-
this.list = new core_1.List(new lists_1.ElementArrayListAdapter(this));
|
|
212
|
-
}
|
|
213
|
-
of(parent) {
|
|
214
|
-
return new TargetNestedElements(parent, this);
|
|
215
|
-
}
|
|
216
|
-
count() {
|
|
217
|
-
return this.list.count();
|
|
218
|
-
}
|
|
219
|
-
first() {
|
|
220
|
-
return this.list.first();
|
|
221
|
-
}
|
|
222
|
-
last() {
|
|
223
|
-
return this.list.last();
|
|
224
|
-
}
|
|
225
|
-
get(index) {
|
|
226
|
-
return this.list.get(index);
|
|
227
|
-
}
|
|
228
|
-
where(question, expectation) {
|
|
229
|
-
return this.list.where(question, expectation);
|
|
230
|
-
}
|
|
231
|
-
answeredBy(actor) {
|
|
232
|
-
return this.locator.allMatching()
|
|
233
|
-
.describedAs(this.subject)
|
|
234
|
-
.answeredBy(actor);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.TargetElements = TargetElements;
|
|
238
|
-
/**
|
|
239
|
-
* @desc
|
|
240
|
-
* You probably don't want to use this class directly. See {@link Target} instead.
|
|
241
|
-
*
|
|
242
|
-
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
243
|
-
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
244
|
-
*
|
|
245
|
-
* @see {@link Target}
|
|
246
|
-
*/
|
|
247
|
-
class TargetNestedElements extends core_1.Question {
|
|
248
|
-
constructor(parent, children) {
|
|
249
|
-
super(`${children} of ${parent}`);
|
|
250
|
-
this.parent = parent;
|
|
251
|
-
this.children = children;
|
|
252
|
-
this.list = new core_1.List(new lists_1.ElementArrayListAdapter(this));
|
|
253
|
-
}
|
|
254
|
-
of(parent) {
|
|
255
|
-
return new TargetNestedElements(parent, this);
|
|
256
|
-
}
|
|
257
|
-
count() {
|
|
258
|
-
return this.list.count();
|
|
259
|
-
}
|
|
260
|
-
first() {
|
|
261
|
-
return this.list.first();
|
|
262
|
-
}
|
|
263
|
-
last() {
|
|
264
|
-
return this.list.last();
|
|
265
|
-
}
|
|
266
|
-
get(index) {
|
|
267
|
-
return this.list.get(index);
|
|
268
|
-
}
|
|
269
|
-
where(question, expectation) {
|
|
270
|
-
return this.list.where(question, expectation);
|
|
271
|
-
}
|
|
272
|
-
async answeredBy(actor) {
|
|
273
|
-
const parent = await actor.answer(this.parent);
|
|
274
|
-
const children = await actor.answer(this.children);
|
|
275
|
-
if (!parent) {
|
|
276
|
-
throw new core_1.LogicError((0, io_1.formatted) `Couldn't find ${this.parent}`);
|
|
277
|
-
}
|
|
278
|
-
return parent.$$(children.selector);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
exports.TargetNestedElements = TargetNestedElements;
|
|
282
|
-
/**
|
|
283
|
-
* @desc
|
|
284
|
-
* You probably don't want to use this class directly. See {@link Target} instead.
|
|
285
|
-
*
|
|
286
|
-
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
287
|
-
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
288
|
-
*
|
|
289
|
-
* @see {@link Target}
|
|
290
|
-
*/
|
|
291
|
-
class TargetElement extends core_1.Question {
|
|
292
|
-
constructor(description, locator) {
|
|
293
|
-
super(description);
|
|
294
|
-
this.locator = locator;
|
|
295
|
-
}
|
|
296
|
-
of(parent) {
|
|
297
|
-
return new TargetNestedElement(parent, this);
|
|
298
|
-
}
|
|
299
|
-
answeredBy(actor) {
|
|
300
|
-
return this.locator.firstMatching()
|
|
301
|
-
.describedAs(this.subject)
|
|
302
|
-
.answeredBy(actor);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
exports.TargetElement = TargetElement;
|
|
306
|
-
/**
|
|
307
|
-
* @desc
|
|
308
|
-
* You probably don't want to use this class directly. See {@link Target} instead.
|
|
309
|
-
*
|
|
310
|
-
* @extends {@serenity-js/core/lib/screenplay~Question}
|
|
311
|
-
* @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
|
|
312
|
-
*
|
|
313
|
-
* @see {@link Target}
|
|
314
|
-
*/
|
|
315
|
-
class TargetNestedElement extends core_1.Question {
|
|
316
|
-
constructor(parent, child) {
|
|
317
|
-
super(`${child} of ${parent}`);
|
|
318
|
-
this.parent = parent;
|
|
319
|
-
this.child = child;
|
|
320
|
-
}
|
|
321
|
-
of(parent) {
|
|
322
|
-
return new TargetNestedElement(parent, this);
|
|
323
|
-
}
|
|
324
|
-
async answeredBy(actor) {
|
|
325
|
-
const parent = await actor.answer(this.parent);
|
|
326
|
-
const child = await actor.answer(this.child);
|
|
327
|
-
if (!parent) {
|
|
328
|
-
throw new core_1.LogicError((0, io_1.formatted) `Couldn't find ${this.parent}`);
|
|
329
|
-
}
|
|
330
|
-
return parent.$(child.selector);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
exports.TargetNestedElement = TargetNestedElement;
|
|
334
|
-
//# sourceMappingURL=targets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targets.js","sourceRoot":"","sources":["../../../src/screenplay/questions/targets.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,4CAAuI;AACvI,iDAAqD;AAGrD,mCAAkD;AAiBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4IG;AACH,MAAa,MAAM;IAEf;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,WAAmB;QAC1B,OAAO;YACH,OAAO,CAAC,OAAgB;gBACpB,OAAO,IAAI,aAAa,CAAC,OAAQ,WAAY,EAAE,EAAE,OAAO,CAAC,CAAC;YAC9D,CAAC;YAED,EAAE,CAAC,MAAoC;gBACnC,OAAO;oBACH,OAAO,CAAC,OAAgB;wBACpB,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;oBACpF,CAAC;iBACJ,CAAA;YACL,CAAC;SACJ,CAAA;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,WAAmB;QAC1B,OAAO;YACH,OAAO,CAAC,OAAgB;gBACpB,OAAO,IAAI,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACpD,CAAC;YAED,EAAE,CAAC,MAAoC;gBACnC,OAAO;oBACH,OAAO,CAAC,OAAgB;wBACpB,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,IAAI,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;oBACtF,CAAC;iBACJ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
"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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stage/crew/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { DomainEvent } from '@serenity-js/core/lib/events';
|
|
2
|
-
import { Stage, StageCrewMember } from '@serenity-js/core/lib/stage';
|
|
3
|
-
import { PhotoTakingStrategy } from './strategies';
|
|
4
|
-
/**
|
|
5
|
-
* @desc
|
|
6
|
-
* The Photographer is a {@link @serenity-js/core/lib/stage~StageCrewMember} who takes screenshots
|
|
7
|
-
* of the web browser that the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight is using.
|
|
8
|
-
*
|
|
9
|
-
* @example <caption>Assigning the Photographer to the Stage</caption>
|
|
10
|
-
* // wdio.conf.ts
|
|
11
|
-
* import { ArtifactArchiver } from '@serenity-js/core';
|
|
12
|
-
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/webdriverio';
|
|
13
|
-
*
|
|
14
|
-
* export const config = {
|
|
15
|
-
*
|
|
16
|
-
* serenity: {
|
|
17
|
-
* crew: [
|
|
18
|
-
* ArtifactArchiver.storingArtifactsAt(process.cwd(), 'target/site/serenity'),
|
|
19
|
-
* Photographer.whoWill(TakePhotosOfFailures),
|
|
20
|
-
* ]
|
|
21
|
-
* },
|
|
22
|
-
*
|
|
23
|
-
* // ... rest of the config omitted for brevity
|
|
24
|
-
* };
|
|
25
|
-
*
|
|
26
|
-
* @example <caption>Taking photos upon failures only</caption>
|
|
27
|
-
*
|
|
28
|
-
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/webdriverio';
|
|
29
|
-
*
|
|
30
|
-
* Photographer.whoWill(TakePhotosOfFailures)
|
|
31
|
-
*
|
|
32
|
-
* @example <caption>Taking photos of all the interactions</caption>
|
|
33
|
-
*
|
|
34
|
-
* import { Photographer, TakePhotosOfInteractions } from '@serenity-js/webdriverio';
|
|
35
|
-
*
|
|
36
|
-
* Photographer.whoWill(TakePhotosOfInteractions)
|
|
37
|
-
*
|
|
38
|
-
* @example <caption>Taking photos before and after all the interactions</caption>
|
|
39
|
-
*
|
|
40
|
-
* import { Photographer, TakePhotosBeforeAndAfterInteractions } from '@serenity-js/webdriverio';
|
|
41
|
-
*
|
|
42
|
-
* Photographer.whoWill(TakePhotosBeforeAndAfterInteractions)
|
|
43
|
-
*
|
|
44
|
-
* @see {@link @serenity-js/core/lib/stage~Stage}
|
|
45
|
-
* @see {@link TakePhotosBeforeAndAfterInteractions}
|
|
46
|
-
* @see {@link TakePhotosOfFailures}
|
|
47
|
-
* @see {@link TakePhotosOfInteractions}
|
|
48
|
-
*/
|
|
49
|
-
export declare class Photographer implements StageCrewMember {
|
|
50
|
-
private readonly photoTakingStrategy;
|
|
51
|
-
private stage?;
|
|
52
|
-
/**
|
|
53
|
-
* @desc
|
|
54
|
-
* Instantiates a new {@link Photographer} configured to take photos (screenshots)
|
|
55
|
-
* as per the specified {@link PhotoTakingStrategy}.
|
|
56
|
-
*
|
|
57
|
-
* @param {Function} strategy - A no-arg constructor function that instantiates a {@link PhotoTakingStrategy}.
|
|
58
|
-
* @returns {StageCrewMember}
|
|
59
|
-
*/
|
|
60
|
-
static whoWill(strategy: new () => PhotoTakingStrategy): StageCrewMember;
|
|
61
|
-
/**
|
|
62
|
-
* @param {PhotoTakingStrategy} photoTakingStrategy
|
|
63
|
-
* @param {Stage} stage
|
|
64
|
-
*/
|
|
65
|
-
constructor(photoTakingStrategy: PhotoTakingStrategy, stage?: Stage);
|
|
66
|
-
/**
|
|
67
|
-
* @desc
|
|
68
|
-
* Creates a new instance of this {@link StageCrewMember} and assigns it to a given {@link Stage}.
|
|
69
|
-
*
|
|
70
|
-
* @param {Stage} stage - An instance of a {@link Stage} this {@link StageCrewMember} will be assigned to
|
|
71
|
-
* @returns {StageCrewMember} - A new instance of this {@link StageCrewMember}
|
|
72
|
-
*/
|
|
73
|
-
assignedTo(stage: Stage): StageCrewMember;
|
|
74
|
-
/**
|
|
75
|
-
* @desc
|
|
76
|
-
* Handles {@link DomainEvent} objects emitted by the {@link Stage}
|
|
77
|
-
* this {@link StageCrewMember} is assigned to.
|
|
78
|
-
*
|
|
79
|
-
* @param {DomainEvent} event
|
|
80
|
-
* @returns {void}
|
|
81
|
-
*/
|
|
82
|
-
notifyOf(event: DomainEvent): void;
|
|
83
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Photographer = void 0;
|
|
4
|
-
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const events_1 = require("@serenity-js/core/lib/events");
|
|
6
|
-
/**
|
|
7
|
-
* @desc
|
|
8
|
-
* The Photographer is a {@link @serenity-js/core/lib/stage~StageCrewMember} who takes screenshots
|
|
9
|
-
* of the web browser that the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight is using.
|
|
10
|
-
*
|
|
11
|
-
* @example <caption>Assigning the Photographer to the Stage</caption>
|
|
12
|
-
* // wdio.conf.ts
|
|
13
|
-
* import { ArtifactArchiver } from '@serenity-js/core';
|
|
14
|
-
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/webdriverio';
|
|
15
|
-
*
|
|
16
|
-
* export const config = {
|
|
17
|
-
*
|
|
18
|
-
* serenity: {
|
|
19
|
-
* crew: [
|
|
20
|
-
* ArtifactArchiver.storingArtifactsAt(process.cwd(), 'target/site/serenity'),
|
|
21
|
-
* Photographer.whoWill(TakePhotosOfFailures),
|
|
22
|
-
* ]
|
|
23
|
-
* },
|
|
24
|
-
*
|
|
25
|
-
* // ... rest of the config omitted for brevity
|
|
26
|
-
* };
|
|
27
|
-
*
|
|
28
|
-
* @example <caption>Taking photos upon failures only</caption>
|
|
29
|
-
*
|
|
30
|
-
* import { Photographer, TakePhotosOfFailures } from '@serenity-js/webdriverio';
|
|
31
|
-
*
|
|
32
|
-
* Photographer.whoWill(TakePhotosOfFailures)
|
|
33
|
-
*
|
|
34
|
-
* @example <caption>Taking photos of all the interactions</caption>
|
|
35
|
-
*
|
|
36
|
-
* import { Photographer, TakePhotosOfInteractions } from '@serenity-js/webdriverio';
|
|
37
|
-
*
|
|
38
|
-
* Photographer.whoWill(TakePhotosOfInteractions)
|
|
39
|
-
*
|
|
40
|
-
* @example <caption>Taking photos before and after all the interactions</caption>
|
|
41
|
-
*
|
|
42
|
-
* import { Photographer, TakePhotosBeforeAndAfterInteractions } from '@serenity-js/webdriverio';
|
|
43
|
-
*
|
|
44
|
-
* Photographer.whoWill(TakePhotosBeforeAndAfterInteractions)
|
|
45
|
-
*
|
|
46
|
-
* @see {@link @serenity-js/core/lib/stage~Stage}
|
|
47
|
-
* @see {@link TakePhotosBeforeAndAfterInteractions}
|
|
48
|
-
* @see {@link TakePhotosOfFailures}
|
|
49
|
-
* @see {@link TakePhotosOfInteractions}
|
|
50
|
-
*/
|
|
51
|
-
class Photographer {
|
|
52
|
-
/**
|
|
53
|
-
* @param {PhotoTakingStrategy} photoTakingStrategy
|
|
54
|
-
* @param {Stage} stage
|
|
55
|
-
*/
|
|
56
|
-
constructor(photoTakingStrategy, stage) {
|
|
57
|
-
this.photoTakingStrategy = photoTakingStrategy;
|
|
58
|
-
this.stage = stage;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @desc
|
|
62
|
-
* Instantiates a new {@link Photographer} configured to take photos (screenshots)
|
|
63
|
-
* as per the specified {@link PhotoTakingStrategy}.
|
|
64
|
-
*
|
|
65
|
-
* @param {Function} strategy - A no-arg constructor function that instantiates a {@link PhotoTakingStrategy}.
|
|
66
|
-
* @returns {StageCrewMember}
|
|
67
|
-
*/
|
|
68
|
-
static whoWill(strategy) {
|
|
69
|
-
return new Photographer(new strategy());
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @desc
|
|
73
|
-
* Creates a new instance of this {@link StageCrewMember} and assigns it to a given {@link Stage}.
|
|
74
|
-
*
|
|
75
|
-
* @param {Stage} stage - An instance of a {@link Stage} this {@link StageCrewMember} will be assigned to
|
|
76
|
-
* @returns {StageCrewMember} - A new instance of this {@link StageCrewMember}
|
|
77
|
-
*/
|
|
78
|
-
assignedTo(stage) {
|
|
79
|
-
return new Photographer(this.photoTakingStrategy, stage);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @desc
|
|
83
|
-
* Handles {@link DomainEvent} objects emitted by the {@link Stage}
|
|
84
|
-
* this {@link StageCrewMember} is assigned to.
|
|
85
|
-
*
|
|
86
|
-
* @param {DomainEvent} event
|
|
87
|
-
* @returns {void}
|
|
88
|
-
*/
|
|
89
|
-
notifyOf(event) {
|
|
90
|
-
if (!this.stage) {
|
|
91
|
-
throw new core_1.LogicError(`Photographer needs to be assigned to the Stage before it can be notified of any DomainEvents`);
|
|
92
|
-
}
|
|
93
|
-
if (!this.stage.theShowHasStarted()) {
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
if (event instanceof events_1.ActivityStarts || event instanceof events_1.ActivityFinished) {
|
|
97
|
-
this.photoTakingStrategy.considerTakingPhoto(event, this.stage);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.Photographer = Photographer;
|
|
102
|
-
//# sourceMappingURL=Photographer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Photographer.js","sourceRoot":"","sources":["../../../../src/stage/crew/photographer/Photographer.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAC/C,yDAA6F;AAK7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAa,YAAY;IAcrB;;;OAGG;IACH,YACqB,mBAAwC,EACjD,KAAa;QADJ,wBAAmB,GAAnB,mBAAmB,CAAqB;QACjD,UAAK,GAAL,KAAK,CAAQ;IAEzB,CAAC;IApBD;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,QAAuC;QAClD,OAAO,IAAI,YAAY,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAYD;;;;;;OAMG;IACH,UAAU,CAAC,KAAY;QACnB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;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;AAxDD,oCAwDC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
__exportStar(require("./strategies"), exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/stage/crew/photographer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Stage } from '@serenity-js/core';
|
|
2
|
-
import { ActivityFinished, ActivityStarts, DomainEvent } from '@serenity-js/core/lib/events';
|
|
3
|
-
/**
|
|
4
|
-
* @desc
|
|
5
|
-
* Configures the {@link Photographer} to take photos (a.k.a. screenshots)
|
|
6
|
-
* of the {@link @serenity-js/core/lib/screenplay~Activity} performed
|
|
7
|
-
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight
|
|
8
|
-
* under specific conditions.
|
|
9
|
-
*
|
|
10
|
-
* @abstract
|
|
11
|
-
*/
|
|
12
|
-
export declare abstract class PhotoTakingStrategy {
|
|
13
|
-
/**
|
|
14
|
-
* @desc
|
|
15
|
-
* Takes a photo of the web browser held by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight.
|
|
16
|
-
*
|
|
17
|
-
* @param {@serenity-js/core/lib/events~ActivityStarts | @serenity-js/core/lib/events~ActivityFinished} event
|
|
18
|
-
* @param {@serenity-js/core/lib/stage~Stage} stage - the Stage that holds reference to the Actor in the spotlight
|
|
19
|
-
* @returns {void}
|
|
20
|
-
*
|
|
21
|
-
* @see {@link @serenity-js/core/lib/stage~Stage#theActorInTheSpotlight}
|
|
22
|
-
*/
|
|
23
|
-
considerTakingPhoto(event: ActivityStarts | ActivityFinished, stage: Stage): void;
|
|
24
|
-
protected abstract shouldTakeAPhotoOf(event: DomainEvent): boolean;
|
|
25
|
-
protected abstract photoNameFor(event: DomainEvent): string;
|
|
26
|
-
private combinedNameFrom;
|
|
27
|
-
private shouldIgnore;
|
|
28
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PhotoTakingStrategy = void 0;
|
|
4
|
-
const events_1 = require("@serenity-js/core/lib/events");
|
|
5
|
-
const model_1 = require("@serenity-js/core/lib/model");
|
|
6
|
-
const screenplay_1 = require("../../../../screenplay");
|
|
7
|
-
/**
|
|
8
|
-
* @desc
|
|
9
|
-
* Configures the {@link Photographer} to take photos (a.k.a. screenshots)
|
|
10
|
-
* of the {@link @serenity-js/core/lib/screenplay~Activity} performed
|
|
11
|
-
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight
|
|
12
|
-
* under specific conditions.
|
|
13
|
-
*
|
|
14
|
-
* @abstract
|
|
15
|
-
*/
|
|
16
|
-
class PhotoTakingStrategy {
|
|
17
|
-
/**
|
|
18
|
-
* @desc
|
|
19
|
-
* Takes a photo of the web browser held by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight.
|
|
20
|
-
*
|
|
21
|
-
* @param {@serenity-js/core/lib/events~ActivityStarts | @serenity-js/core/lib/events~ActivityFinished} event
|
|
22
|
-
* @param {@serenity-js/core/lib/stage~Stage} stage - the Stage that holds reference to the Actor in the spotlight
|
|
23
|
-
* @returns {void}
|
|
24
|
-
*
|
|
25
|
-
* @see {@link @serenity-js/core/lib/stage~Stage#theActorInTheSpotlight}
|
|
26
|
-
*/
|
|
27
|
-
considerTakingPhoto(event, stage) {
|
|
28
|
-
if (this.shouldTakeAPhotoOf(event)) {
|
|
29
|
-
let browseTheWeb;
|
|
30
|
-
try {
|
|
31
|
-
browseTheWeb = screenplay_1.BrowseTheWeb.as(stage.theActorInTheSpotlight());
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
const id = model_1.CorrelationId.create(), nameSuffix = this.photoNameFor(event),
|
|
37
|
-
// todo: test if this type def is really DesiredCapabilities when multi-capabilities are used
|
|
38
|
-
capabilities = browseTheWeb.browser.capabilities;
|
|
39
|
-
stage.announce(new events_1.AsyncOperationAttempted(new model_1.Description(`[Photographer:${this.constructor.name}] Taking screenshot of '${nameSuffix}'...`), id));
|
|
40
|
-
browseTheWeb.takeScreenshot().then(screenshot => {
|
|
41
|
-
const context = [capabilities.platformName, capabilities.browserName, capabilities.browserVersion], photoName = this.combinedNameFrom(...context, nameSuffix);
|
|
42
|
-
stage.announce(new events_1.ActivityRelatedArtifactGenerated(event.sceneId, event.activityId, photoName, model_1.Photo.fromBase64(screenshot)));
|
|
43
|
-
stage.announce(new events_1.AsyncOperationCompleted(new model_1.Description(`[${this.constructor.name}] Took screenshot of '${nameSuffix}' on ${context}`), id));
|
|
44
|
-
}).catch(error => {
|
|
45
|
-
if (this.shouldIgnore(error)) {
|
|
46
|
-
stage.announce(new events_1.AsyncOperationCompleted(new model_1.Description(`[${this.constructor.name}] Aborted taking screenshot of '${nameSuffix}' because of ${error.constructor && error.constructor.name}`), id));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
stage.announce(new events_1.AsyncOperationFailed(error, id));
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
combinedNameFrom(...parts) {
|
|
55
|
-
return new model_1.Name(parts.filter(v => !!v).join('-'));
|
|
56
|
-
}
|
|
57
|
-
shouldIgnore(error) {
|
|
58
|
-
// todo
|
|
59
|
-
// return error instanceof webdriver.NoSuchSessionError
|
|
60
|
-
// || error instanceof webdriver.UnexpectedAlertOpenError
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.PhotoTakingStrategy = PhotoTakingStrategy;
|
|
65
|
-
//# sourceMappingURL=PhotoTakingStrategy.js.map
|