@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,83 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/stage/crew/photographer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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): Promise<void>;
|
|
24
|
+
protected abstract shouldTakeAPhotoOf(event: DomainEvent): boolean;
|
|
25
|
+
protected abstract photoNameFor(event: DomainEvent): string;
|
|
26
|
+
private combinedNameFrom;
|
|
27
|
+
private shouldIgnore;
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
async considerTakingPhoto(event, stage) {
|
|
28
|
+
if (!this.shouldTakeAPhotoOf(event)) {
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
let browseTheWeb;
|
|
32
|
+
try {
|
|
33
|
+
browseTheWeb = screenplay_1.BrowseTheWeb.as(stage.theActorInTheSpotlight());
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// actor doesn't have a browser, abort
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
const id = model_1.CorrelationId.create(), nameSuffix = this.photoNameFor(event);
|
|
40
|
+
stage.announce(new events_1.AsyncOperationAttempted(new model_1.Description(`[Photographer:${this.constructor.name}] Taking screenshot of '${nameSuffix}'...`), id));
|
|
41
|
+
let dialogIsPresent;
|
|
42
|
+
try {
|
|
43
|
+
dialogIsPresent = await browseTheWeb.modalDialog().then(dialog => dialog.isPresent());
|
|
44
|
+
if (dialogIsPresent) {
|
|
45
|
+
return stage.announce(new events_1.AsyncOperationCompleted(new model_1.Description(`[${this.constructor.name}] Aborted taking screenshot of '${nameSuffix}' because of a modal dialog obstructing the view`), id));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return stage.announce(new events_1.AsyncOperationFailed(error, id));
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const [screenshot, capabilities] = await Promise.all([
|
|
53
|
+
browseTheWeb.takeScreenshot(),
|
|
54
|
+
browseTheWeb.browserCapabilities(),
|
|
55
|
+
]);
|
|
56
|
+
const context = [capabilities.platformName, capabilities.browserName, capabilities.browserVersion], photoName = this.combinedNameFrom(...context, nameSuffix);
|
|
57
|
+
stage.announce(new events_1.ActivityRelatedArtifactGenerated(event.sceneId, event.activityId, photoName, model_1.Photo.fromBase64(screenshot)));
|
|
58
|
+
return stage.announce(new events_1.AsyncOperationCompleted(new model_1.Description(`[${this.constructor.name}] Took screenshot of '${nameSuffix}' on ${context}`), id));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (this.shouldIgnore(error)) {
|
|
62
|
+
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));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
stage.announce(new events_1.AsyncOperationFailed(error, id));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
combinedNameFrom(...parts) {
|
|
70
|
+
return new model_1.Name(parts.filter(v => !!v).join('-'));
|
|
71
|
+
}
|
|
72
|
+
shouldIgnore(error) {
|
|
73
|
+
return error.name
|
|
74
|
+
&& (error.name === 'NoSuchSessionError');
|
|
75
|
+
// todo: add SauceLabs
|
|
76
|
+
// [0-0] 2021-12-02T01:32:36.402Z ERROR webdriver: Request failed with status 404 due to no such window: no such window: target window already closed
|
|
77
|
+
// [0-0] from unknown error: web view not found
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PhotoTakingStrategy = PhotoTakingStrategy;
|
|
81
|
+
//# sourceMappingURL=PhotoTakingStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhotoTakingStrategy.js","sourceRoot":"","sources":["../../../../../src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts"],"names":[],"mappings":";;;AACA,yDAAuM;AACvM,uDAAsF;AAEtF,uDAAsD;AAEtD;;;;;;;;GAQG;AACH,MAAsB,mBAAmB;IAErC;;;;;;;;;OASG;IACH,KAAK,CAAC,mBAAmB,CAAC,KAAwC,EAAE,KAAY;QAC5E,IAAI,CAAE,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC,CAAC;SACjB;QAED,IAAI,YAA0B,CAAC;QAE/B,IAAI;YACA,YAAY,GAAG,yBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC,CAAC;SAClE;QAAC,MAAM;YACJ,sCAAsC;YACtC,OAAO,KAAK,CAAC,CAAC;SACjB;QAED,MACI,EAAE,GAAgB,qBAAa,CAAC,MAAM,EAAE,EACxC,UAAU,GAAQ,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAE/C,KAAK,CAAC,QAAQ,CAAC,IAAI,gCAAuB,CACtC,IAAI,mBAAW,CAAC,iBAAkB,IAAI,CAAC,WAAW,CAAC,IAAK,2BAA4B,UAAW,MAAM,CAAC,EACtG,EAAE,CACL,CAAC,CAAC;QAEH,IAAI,eAAwB,CAAC;QAE7B,IAAI;YACA,eAAe,GAAG,MAAM,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YAEtF,IAAI,eAAe,EAAE;gBACjB,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,gCAAuB,CAC7C,IAAI,mBAAW,CAAC,IAAK,IAAI,CAAC,WAAW,CAAC,IAAK,mCAAoC,UAAW,kDAAkD,CAAC,EAC7I,EAAE,CACL,CAAC,CAAC;aACN;SACJ;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,6BAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;SAC9D;QAED,IAAI;YACA,MAAM,CAAE,UAAU,EAAE,YAAY,CAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACnD,YAAY,CAAC,cAAc,EAAE;gBAC7B,YAAY,CAAC,mBAAmB,EAAE;aACrC,CAAC,CAAC;YAEH,MACI,OAAO,GAAK,CAAE,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,cAAc,CAAE,EAChG,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC;YAE9D,KAAK,CAAC,QAAQ,CAAC,IAAI,yCAAgC,CAC/C,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,UAAU,EAChB,SAAS,EACT,aAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAC/B,CAAC,CAAC;YAEH,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,gCAAuB,CAC7C,IAAI,mBAAW,CAAC,IAAK,IAAI,CAAC,WAAW,CAAC,IAAK,yBAA0B,UAAW,QAAS,OAAQ,EAAE,CAAC,EACpG,EAAE,CACL,CAAC,CAAC;SACN;QACD,OAAO,KAAK,EAAE;YACV,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;gBAC1B,KAAK,CAAC,QAAQ,CAAC,IAAI,gCAAuB,CACtC,IAAI,mBAAW,CAAC,IAAK,IAAI,CAAC,WAAW,CAAC,IAAK,mCAAoC,UAAW,gBAAiB,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC,IAAK,EAAE,CAAC,EAC1J,EAAE,CACL,CAAC,CAAC;aACN;iBACI;gBACD,KAAK,CAAC,QAAQ,CAAC,IAAI,6BAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;aACvD;SACJ;IACL,CAAC;IAMO,gBAAgB,CAAC,GAAG,KAAe;QACvC,OAAO,IAAI,YAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,CAAC;IAEO,YAAY,CAAC,KAAY;QAC7B,OAAO,KAAK,CAAC,IAAI;eACV,CAAC,KAAK,CAAC,IAAI,KAAK,oBAAoB,CAAC,CAAC;QAC7C,sBAAsB;QACtB,sJAAsJ;QACtJ,gDAAgD;IACpD,CAAC;CACJ;AApGD,kDAoGC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DomainEvent, InteractionFinished, InteractionStarts } from '@serenity-js/core/lib/events';
|
|
2
|
+
import { PhotoTakingStrategy } from './PhotoTakingStrategy';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) both before and after
|
|
6
|
+
* every single {@link @serenity-js/core/lib/screenplay~Interaction} performed
|
|
7
|
+
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight.
|
|
8
|
+
*
|
|
9
|
+
* *Please note* that this strategy will result in _a lot_ of screenshots being taken,
|
|
10
|
+
* which will seriously affect the performance of your tests.
|
|
11
|
+
* For this reason, it's best to use it only for debugging purposes.
|
|
12
|
+
*
|
|
13
|
+
* @extends {PhotoTakingStrategy}
|
|
14
|
+
*/
|
|
15
|
+
export declare class TakePhotosBeforeAndAfterInteractions extends PhotoTakingStrategy {
|
|
16
|
+
protected shouldTakeAPhotoOf(event: DomainEvent): boolean;
|
|
17
|
+
protected photoNameFor(event: InteractionStarts | InteractionFinished): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TakePhotosBeforeAndAfterInteractions = void 0;
|
|
4
|
+
const events_1 = require("@serenity-js/core/lib/events");
|
|
5
|
+
const PhotoTakingStrategy_1 = require("./PhotoTakingStrategy");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) both before and after
|
|
9
|
+
* every single {@link @serenity-js/core/lib/screenplay~Interaction} performed
|
|
10
|
+
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight.
|
|
11
|
+
*
|
|
12
|
+
* *Please note* that this strategy will result in _a lot_ of screenshots being taken,
|
|
13
|
+
* which will seriously affect the performance of your tests.
|
|
14
|
+
* For this reason, it's best to use it only for debugging purposes.
|
|
15
|
+
*
|
|
16
|
+
* @extends {PhotoTakingStrategy}
|
|
17
|
+
*/
|
|
18
|
+
class TakePhotosBeforeAndAfterInteractions extends PhotoTakingStrategy_1.PhotoTakingStrategy {
|
|
19
|
+
shouldTakeAPhotoOf(event) {
|
|
20
|
+
return event instanceof events_1.InteractionStarts
|
|
21
|
+
|| event instanceof events_1.InteractionFinished;
|
|
22
|
+
}
|
|
23
|
+
photoNameFor(event) {
|
|
24
|
+
return event instanceof events_1.InteractionStarts
|
|
25
|
+
? `Before ${event.details.name.value}`
|
|
26
|
+
: `After ${event.details.name.value}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.TakePhotosBeforeAndAfterInteractions = TakePhotosBeforeAndAfterInteractions;
|
|
30
|
+
//# sourceMappingURL=TakePhotosBeforeAndAfterInteractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TakePhotosBeforeAndAfterInteractions.js","sourceRoot":"","sources":["../../../../../src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts"],"names":[],"mappings":";;;AAAA,yDAAmG;AAEnG,+DAA4D;AAE5D;;;;;;;;;;;GAWG;AACH,MAAa,oCAAqC,SAAQ,yCAAmB;IAC/D,kBAAkB,CAAC,KAAkB;QAC3C,OAAO,KAAK,YAAY,0BAAiB;eAClC,KAAK,YAAY,4BAAmB,CAAC;IAChD,CAAC;IAES,YAAY,CAAC,KAA8C;QACjE,OAAO,KAAK,YAAY,0BAAiB;YACrC,CAAC,CAAC,UAAW,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAM,EAAE;YACxC,CAAC,CAAC,SAAU,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAM,EAAE,CAAC;IAChD,CAAC;CACJ;AAXD,oFAWC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DomainEvent, InteractionFinished } from '@serenity-js/core/lib/events';
|
|
2
|
+
import { PhotoTakingStrategy } from './PhotoTakingStrategy';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) when
|
|
6
|
+
* the {@link @serenity-js/core/lib/screenplay~Interaction} performed
|
|
7
|
+
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight results in an error.
|
|
8
|
+
*
|
|
9
|
+
* This strategy works best when you are interested in the screenshots only when
|
|
10
|
+
* a scenario fails.
|
|
11
|
+
*
|
|
12
|
+
* @extends {PhotoTakingStrategy}
|
|
13
|
+
*/
|
|
14
|
+
export declare class TakePhotosOfFailures extends PhotoTakingStrategy {
|
|
15
|
+
protected shouldTakeAPhotoOf(event: DomainEvent): boolean;
|
|
16
|
+
protected photoNameFor(event: InteractionFinished): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TakePhotosOfFailures = void 0;
|
|
4
|
+
const events_1 = require("@serenity-js/core/lib/events");
|
|
5
|
+
const model_1 = require("@serenity-js/core/lib/model");
|
|
6
|
+
const PhotoTakingStrategy_1 = require("./PhotoTakingStrategy");
|
|
7
|
+
/**
|
|
8
|
+
* @desc
|
|
9
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) when
|
|
10
|
+
* the {@link @serenity-js/core/lib/screenplay~Interaction} performed
|
|
11
|
+
* by the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight results in an error.
|
|
12
|
+
*
|
|
13
|
+
* This strategy works best when you are interested in the screenshots only when
|
|
14
|
+
* a scenario fails.
|
|
15
|
+
*
|
|
16
|
+
* @extends {PhotoTakingStrategy}
|
|
17
|
+
*/
|
|
18
|
+
class TakePhotosOfFailures extends PhotoTakingStrategy_1.PhotoTakingStrategy {
|
|
19
|
+
shouldTakeAPhotoOf(event) {
|
|
20
|
+
return event instanceof events_1.InteractionFinished
|
|
21
|
+
&& event.outcome.isWorseThan(model_1.ImplementationPending);
|
|
22
|
+
}
|
|
23
|
+
photoNameFor(event) {
|
|
24
|
+
return event.details.name.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TakePhotosOfFailures = TakePhotosOfFailures;
|
|
28
|
+
//# sourceMappingURL=TakePhotosOfFailures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TakePhotosOfFailures.js","sourceRoot":"","sources":["../../../../../src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts"],"names":[],"mappings":";;;AAAA,yDAAgF;AAChF,uDAAoE;AAEpE,+DAA4D;AAE5D;;;;;;;;;;GAUG;AACH,MAAa,oBAAqB,SAAQ,yCAAmB;IAC/C,kBAAkB,CAAC,KAAkB;QAC3C,OAAO,KAAK,YAAY,4BAAmB;eACpC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,6BAAqB,CAAC,CAAC;IAC5D,CAAC;IAES,YAAY,CAAC,KAA0B;QAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IACpC,CAAC;CACJ;AATD,oDASC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DomainEvent, InteractionFinished } from '@serenity-js/core/lib/events';
|
|
2
|
+
import { PhotoTakingStrategy } from './PhotoTakingStrategy';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) when
|
|
6
|
+
* the the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight
|
|
7
|
+
* performs any {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
8
|
+
*
|
|
9
|
+
* This strategy works best when you want the results of your automated tests
|
|
10
|
+
* to become comprehensive living documentation of your system.
|
|
11
|
+
*
|
|
12
|
+
* *Please note* that taking screenshots affects the performance of your tests.
|
|
13
|
+
*
|
|
14
|
+
* @extends {PhotoTakingStrategy}
|
|
15
|
+
*/
|
|
16
|
+
export declare class TakePhotosOfInteractions extends PhotoTakingStrategy {
|
|
17
|
+
protected shouldTakeAPhotoOf(event: DomainEvent): boolean;
|
|
18
|
+
protected photoNameFor(event: InteractionFinished): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TakePhotosOfInteractions = void 0;
|
|
4
|
+
const events_1 = require("@serenity-js/core/lib/events");
|
|
5
|
+
const PhotoTakingStrategy_1 = require("./PhotoTakingStrategy");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Configures the {@link Photographer} to take photos (a.k.a. screenshots) when
|
|
9
|
+
* the the {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight
|
|
10
|
+
* performs any {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
11
|
+
*
|
|
12
|
+
* This strategy works best when you want the results of your automated tests
|
|
13
|
+
* to become comprehensive living documentation of your system.
|
|
14
|
+
*
|
|
15
|
+
* *Please note* that taking screenshots affects the performance of your tests.
|
|
16
|
+
*
|
|
17
|
+
* @extends {PhotoTakingStrategy}
|
|
18
|
+
*/
|
|
19
|
+
class TakePhotosOfInteractions extends PhotoTakingStrategy_1.PhotoTakingStrategy {
|
|
20
|
+
shouldTakeAPhotoOf(event) {
|
|
21
|
+
return event instanceof events_1.InteractionFinished;
|
|
22
|
+
}
|
|
23
|
+
photoNameFor(event) {
|
|
24
|
+
return event.details.name.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.TakePhotosOfInteractions = TakePhotosOfInteractions;
|
|
28
|
+
//# sourceMappingURL=TakePhotosOfInteractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TakePhotosOfInteractions.js","sourceRoot":"","sources":["../../../../../src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts"],"names":[],"mappings":";;;AAAA,yDAAgF;AAEhF,+DAA4D;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAa,wBAAyB,SAAQ,yCAAmB;IACnD,kBAAkB,CAAC,KAAkB;QAC3C,OAAO,KAAK,YAAY,4BAAmB,CAAC;IAChD,CAAC;IAES,YAAY,CAAC,KAA0B;QAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IACpC,CAAC;CACJ;AARD,4DAQC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./PhotoTakingStrategy"), exports);
|
|
14
|
+
__exportStar(require("./TakePhotosBeforeAndAfterInteractions"), exports);
|
|
15
|
+
__exportStar(require("./TakePhotosOfFailures"), exports);
|
|
16
|
+
__exportStar(require("./TakePhotosOfInteractions"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/stage/crew/photographer/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAsC;AACtC,yEAAuD;AACvD,yDAAuC;AACvC,6DAA2C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './crew';
|
|
@@ -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("./crew"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@serenity-js/web",
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
|
+
"description": "Serenity/JS Screenplay Pattern APIs for the Web",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Jan Molak",
|
|
7
|
+
"email": "jan.molak@smartcodeltd.co.uk",
|
|
8
|
+
"url": "https://janmolak.com"
|
|
9
|
+
},
|
|
10
|
+
"funding": {
|
|
11
|
+
"url": "https://github.com/sponsors/serenity-js"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://serenity-js.org",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"main": "lib/index.js",
|
|
19
|
+
"typings": "lib/index.d.ts",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"serenity-js",
|
|
22
|
+
"mocha",
|
|
23
|
+
"tdd",
|
|
24
|
+
"bdd",
|
|
25
|
+
"test",
|
|
26
|
+
"testing",
|
|
27
|
+
"web"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"clean": "rimraf .nyc_output lib target",
|
|
31
|
+
"lint": "eslint --ext ts --config ../../.eslintrc.js .",
|
|
32
|
+
"lint:fix": "npm run lint -- --fix",
|
|
33
|
+
"test": "nyc --report-dir ../../target/coverage/web mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
|
|
34
|
+
"compile": "tsc --project tsconfig.json",
|
|
35
|
+
"site": "esdoc -c .esdoc.js"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/serenity-js/serenity-js.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/serenity-js/serenity-js/issues"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": "^14 || ^16",
|
|
46
|
+
"npm": "^6 || ^7"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@serenity-js/assertions": "3.0.0-rc.0",
|
|
50
|
+
"@serenity-js/core": "3.0.0-rc.0",
|
|
51
|
+
"tiny-types": "^1.16.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@documentation/esdoc-template": "2.0.0",
|
|
55
|
+
"@integration/testing-tools": "2.0.0",
|
|
56
|
+
"@types/chai": "^4.3.0",
|
|
57
|
+
"@types/mocha": "^9.0.0",
|
|
58
|
+
"mocha": "^9.1.3",
|
|
59
|
+
"ts-node": "^10.4.0",
|
|
60
|
+
"typescript": "^4.5.2"
|
|
61
|
+
},
|
|
62
|
+
"nyc": {
|
|
63
|
+
"include": [
|
|
64
|
+
"src/**/*.ts"
|
|
65
|
+
],
|
|
66
|
+
"exclude": [
|
|
67
|
+
"src/**/*.d.ts",
|
|
68
|
+
"lib",
|
|
69
|
+
"node_modules",
|
|
70
|
+
"spec"
|
|
71
|
+
],
|
|
72
|
+
"extension": [
|
|
73
|
+
".ts"
|
|
74
|
+
],
|
|
75
|
+
"require": [
|
|
76
|
+
"ts-node/register"
|
|
77
|
+
],
|
|
78
|
+
"reporter": [
|
|
79
|
+
"json"
|
|
80
|
+
],
|
|
81
|
+
"cache": true,
|
|
82
|
+
"all": true
|
|
83
|
+
},
|
|
84
|
+
"gitHead": "a63381d088cc068bc3edcbd1eb59a7e609cb6a8c"
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CookieMissingError';
|