@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,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Press = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
|
+
const input_1 = require("../../input");
|
|
7
|
+
const abilities_1 = require("../abilities");
|
|
8
|
+
const PageElementInteraction_1 = require("./PageElementInteraction");
|
|
9
|
+
/**
|
|
10
|
+
* @desc
|
|
11
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
12
|
+
* send a key press or a sequence of keys to a Web element.
|
|
13
|
+
*
|
|
14
|
+
* *Please note*: On macOS, some keyboard shortcuts might not work with the [`devtools` protocol](https://webdriver.io/docs/automationProtocols/#devtools-protocol).
|
|
15
|
+
*
|
|
16
|
+
* For example:
|
|
17
|
+
* - to *copy*, instead of `Meta+C`, use `Control+Insert`
|
|
18
|
+
* - to *cut*, instead of `Meta+X`, use `Control+Delete`
|
|
19
|
+
* - to *paste*, instead of `Meta+V`, use `Shift+Insert`
|
|
20
|
+
*
|
|
21
|
+
* @example <caption>Example widget</caption>
|
|
22
|
+
* <form>
|
|
23
|
+
* <input type="text" name="example" id="example" />
|
|
24
|
+
* </form>
|
|
25
|
+
*
|
|
26
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
27
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
28
|
+
*
|
|
29
|
+
* class Form {
|
|
30
|
+
* static exampleInput = Target.the('example input')
|
|
31
|
+
* .located(by.id('example'));
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example <caption>Pressing keys</caption>
|
|
35
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
36
|
+
* import { BrowseTheWeb, Key, Press, Value } from '@serenity-js/webdriverio';
|
|
37
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
38
|
+
*
|
|
39
|
+
* actorCalled('Priyanka')
|
|
40
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
41
|
+
* .attemptsTo(
|
|
42
|
+
* Press.the('H', 'i', '!', Key.ENTER).in(Form.exampleInput),
|
|
43
|
+
* Ensure.that(Value.of(Form.exampleInput), equals('Hi!')),
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* @see {@link Key}
|
|
47
|
+
* @see {@link BrowseTheWeb}
|
|
48
|
+
* @see {@link Target}
|
|
49
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
50
|
+
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
51
|
+
*
|
|
52
|
+
* @extends {ElementInteraction}
|
|
53
|
+
*/
|
|
54
|
+
class Press extends PageElementInteraction_1.PageElementInteraction {
|
|
55
|
+
/**
|
|
56
|
+
* @param {Answerable<Array<Key | string>>} keys
|
|
57
|
+
* A sequence of one or more keys to press
|
|
58
|
+
*/
|
|
59
|
+
constructor(keys) {
|
|
60
|
+
super((0, io_1.formatted) `#actor presses ${keys}`);
|
|
61
|
+
this.keys = keys;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @desc
|
|
65
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
66
|
+
*
|
|
67
|
+
* @param {...keys: Array<Answerable<Key | string | Key[] | string[]>>} keys
|
|
68
|
+
* A sequence of one or more keys to press
|
|
69
|
+
*
|
|
70
|
+
* @returns {PressBuilder}
|
|
71
|
+
*/
|
|
72
|
+
static the(...keys) {
|
|
73
|
+
return new Press(KeySequence.of(keys));
|
|
74
|
+
}
|
|
75
|
+
in(field /* | Question<AlertPromise> | AlertPromise */) {
|
|
76
|
+
return new PressKeyInField(this.keys, field);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @desc
|
|
80
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
81
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
82
|
+
*
|
|
83
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
84
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
85
|
+
*
|
|
86
|
+
* @returns {PromiseLike<void>}
|
|
87
|
+
*
|
|
88
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
89
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
90
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
91
|
+
*/
|
|
92
|
+
async performAs(actor) {
|
|
93
|
+
const keys = await actor.answer(this.keys);
|
|
94
|
+
return abilities_1.BrowseTheWeb.as(actor).sendKeys(keys);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.Press = Press;
|
|
98
|
+
class PressKeyInField extends PageElementInteraction_1.PageElementInteraction {
|
|
99
|
+
/**
|
|
100
|
+
* @param {Answerable<Array<Key | string>>} keys
|
|
101
|
+
* A sequence of one or more keys to press
|
|
102
|
+
*
|
|
103
|
+
* @param {Answerable<PageElement>} field
|
|
104
|
+
* Web element to send the keys to
|
|
105
|
+
*/
|
|
106
|
+
constructor(keys, field /* todo | Question<AlertPromise> | AlertPromise */) {
|
|
107
|
+
super((0, io_1.formatted) `#actor presses ${keys} in ${field}`);
|
|
108
|
+
this.keys = keys;
|
|
109
|
+
this.field = field;
|
|
110
|
+
}
|
|
111
|
+
async performAs(actor) {
|
|
112
|
+
const field = await this.resolve(actor, this.field);
|
|
113
|
+
const keys = await actor.answer(this.keys);
|
|
114
|
+
// fix for protractor
|
|
115
|
+
// todo: should this wait on focus to occur?
|
|
116
|
+
await abilities_1.BrowseTheWeb.as(actor).executeScript(
|
|
117
|
+
/* istanbul ignore next */
|
|
118
|
+
function focus(element) {
|
|
119
|
+
element.focus();
|
|
120
|
+
}, await field.nativeElement());
|
|
121
|
+
return abilities_1.BrowseTheWeb.as(actor).sendKeys(keys);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @package
|
|
126
|
+
*/
|
|
127
|
+
class KeySequence extends core_1.Question {
|
|
128
|
+
constructor(keys) {
|
|
129
|
+
super();
|
|
130
|
+
this.keys = keys;
|
|
131
|
+
this.subject = KeySequence.describe(keys);
|
|
132
|
+
}
|
|
133
|
+
static of(keys) {
|
|
134
|
+
return new KeySequence(keys);
|
|
135
|
+
}
|
|
136
|
+
answeredBy(actor) {
|
|
137
|
+
return Promise.all(this.keys.map(part => actor.answer(part))).then(keys => {
|
|
138
|
+
return keys.flat().filter(key => !!key);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @desc
|
|
143
|
+
* Changes the description of this question's subject.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} subject
|
|
146
|
+
* @returns {Question<T>}
|
|
147
|
+
*/
|
|
148
|
+
describedAs(subject) {
|
|
149
|
+
this.subject = subject;
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
toString() {
|
|
153
|
+
return this.subject;
|
|
154
|
+
}
|
|
155
|
+
static describe(keys) {
|
|
156
|
+
const prefix = keys.length === 1 ? 'key' : 'keys';
|
|
157
|
+
const description = keys.reduce((acc, key, index) => {
|
|
158
|
+
const separator = input_1.Key.isKey(key) && key.isModifier
|
|
159
|
+
? '-'
|
|
160
|
+
: acc.separator;
|
|
161
|
+
return {
|
|
162
|
+
description: index === 0
|
|
163
|
+
? `${key}`
|
|
164
|
+
: `${acc.description}${acc.separator}${key}`,
|
|
165
|
+
separator,
|
|
166
|
+
};
|
|
167
|
+
}, { description: '', separator: ', ' }).description;
|
|
168
|
+
return `${prefix} ${description}`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=Press.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Press.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Press.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Answerable } from '@serenity-js/core';
|
|
2
|
+
import { Interaction } from '@serenity-js/core/lib/screenplay';
|
|
3
|
+
import { PageElement } from '../models';
|
|
4
|
+
/**
|
|
5
|
+
* @desc
|
|
6
|
+
* Fluent interface to make the instantiation of
|
|
7
|
+
* the {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
8
|
+
* to {@link Press} more readable.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link Press}
|
|
11
|
+
*
|
|
12
|
+
* @interface
|
|
13
|
+
*/
|
|
14
|
+
export interface PressBuilder {
|
|
15
|
+
/**
|
|
16
|
+
* @desc
|
|
17
|
+
* Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
18
|
+
* to {@link Press}.
|
|
19
|
+
*
|
|
20
|
+
* @param {Answerable<PageElement>} field
|
|
21
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
22
|
+
*
|
|
23
|
+
* @see {@link Target}
|
|
24
|
+
*/
|
|
25
|
+
in: (field: Answerable<PageElement>) => Interaction;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PressBuilder.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/PressBuilder.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from '../models';
|
|
3
|
+
import { PageElementInteraction } from './PageElementInteraction';
|
|
4
|
+
/**
|
|
5
|
+
* @desc
|
|
6
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
7
|
+
* perfom a right click on a given Web element.
|
|
8
|
+
*
|
|
9
|
+
* This is typically used to open a [custom context menu](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)
|
|
10
|
+
* on a given Web element, since it's not possible to interact with the standard context menu offered by your browser
|
|
11
|
+
*
|
|
12
|
+
* @example <caption>Example widget</caption>
|
|
13
|
+
* <form>
|
|
14
|
+
* <input type="text" id="field"
|
|
15
|
+
* oncontextmenu="showMenu(); return false;" />
|
|
16
|
+
*
|
|
17
|
+
* <div id="context-menu" style="display:none">
|
|
18
|
+
* Custom context menu
|
|
19
|
+
* </div>
|
|
20
|
+
* </form>
|
|
21
|
+
*
|
|
22
|
+
* <script>
|
|
23
|
+
* function showMenu() {
|
|
24
|
+
* document.getElementById("context-menu").style.display = 'block';
|
|
25
|
+
* }
|
|
26
|
+
* </script>
|
|
27
|
+
*
|
|
28
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
29
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
30
|
+
*
|
|
31
|
+
* class Form {
|
|
32
|
+
* static exampleInput = Target.the('example input')
|
|
33
|
+
* .located(by.id('example'));
|
|
34
|
+
* static exampleContextMenu = Target.the('example context menu')
|
|
35
|
+
* .located(by.id('context-menu'));
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* @example <caption>Right-click on an element</caption>
|
|
39
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
40
|
+
* import { BrowseTheWeb, RightClick, isVisible } from '@serenity-js/webdriverio';
|
|
41
|
+
* import { Ensure } from '@serenity-js/assertions';
|
|
42
|
+
*
|
|
43
|
+
* actorCalled('Chloé')
|
|
44
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
45
|
+
* .attemptsTo(
|
|
46
|
+
* RightClick.on(Form.exampleInput),
|
|
47
|
+
* Ensure.that(Form.exampleContextMenu, isVisible()),
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* @see {@link BrowseTheWeb}
|
|
51
|
+
* @see {@link Target}
|
|
52
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
53
|
+
* @see {@link isVisible}
|
|
54
|
+
*
|
|
55
|
+
* @extends {ElementInteraction}
|
|
56
|
+
*/
|
|
57
|
+
export declare class RightClick extends PageElementInteraction {
|
|
58
|
+
private readonly target;
|
|
59
|
+
/**
|
|
60
|
+
* @desc
|
|
61
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
62
|
+
*
|
|
63
|
+
* @param {Answerable<PageElement>} target
|
|
64
|
+
* The element to be right-clicked on
|
|
65
|
+
*
|
|
66
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
67
|
+
*/
|
|
68
|
+
static on(target: Answerable<PageElement>): Interaction;
|
|
69
|
+
/**
|
|
70
|
+
* @param {Answerable<PageElement>} target
|
|
71
|
+
* The element to be right-clicked on
|
|
72
|
+
*/
|
|
73
|
+
constructor(target: Answerable<PageElement>);
|
|
74
|
+
/**
|
|
75
|
+
* @desc
|
|
76
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
77
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
78
|
+
*
|
|
79
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
80
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
81
|
+
*
|
|
82
|
+
* @returns {PromiseLike<void>}
|
|
83
|
+
*
|
|
84
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
85
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
86
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
87
|
+
*/
|
|
88
|
+
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RightClick = void 0;
|
|
4
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
5
|
+
const PageElementInteraction_1 = require("./PageElementInteraction");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
9
|
+
* perfom a right click on a given Web element.
|
|
10
|
+
*
|
|
11
|
+
* This is typically used to open a [custom context menu](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)
|
|
12
|
+
* on a given Web element, since it's not possible to interact with the standard context menu offered by your browser
|
|
13
|
+
*
|
|
14
|
+
* @example <caption>Example widget</caption>
|
|
15
|
+
* <form>
|
|
16
|
+
* <input type="text" id="field"
|
|
17
|
+
* oncontextmenu="showMenu(); return false;" />
|
|
18
|
+
*
|
|
19
|
+
* <div id="context-menu" style="display:none">
|
|
20
|
+
* Custom context menu
|
|
21
|
+
* </div>
|
|
22
|
+
* </form>
|
|
23
|
+
*
|
|
24
|
+
* <script>
|
|
25
|
+
* function showMenu() {
|
|
26
|
+
* document.getElementById("context-menu").style.display = 'block';
|
|
27
|
+
* }
|
|
28
|
+
* </script>
|
|
29
|
+
*
|
|
30
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
31
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
32
|
+
*
|
|
33
|
+
* class Form {
|
|
34
|
+
* static exampleInput = Target.the('example input')
|
|
35
|
+
* .located(by.id('example'));
|
|
36
|
+
* static exampleContextMenu = Target.the('example context menu')
|
|
37
|
+
* .located(by.id('context-menu'));
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* @example <caption>Right-click on an element</caption>
|
|
41
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
42
|
+
* import { BrowseTheWeb, RightClick, isVisible } from '@serenity-js/webdriverio';
|
|
43
|
+
* import { Ensure } from '@serenity-js/assertions';
|
|
44
|
+
*
|
|
45
|
+
* actorCalled('Chloé')
|
|
46
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
47
|
+
* .attemptsTo(
|
|
48
|
+
* RightClick.on(Form.exampleInput),
|
|
49
|
+
* Ensure.that(Form.exampleContextMenu, isVisible()),
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* @see {@link BrowseTheWeb}
|
|
53
|
+
* @see {@link Target}
|
|
54
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
55
|
+
* @see {@link isVisible}
|
|
56
|
+
*
|
|
57
|
+
* @extends {ElementInteraction}
|
|
58
|
+
*/
|
|
59
|
+
class RightClick extends PageElementInteraction_1.PageElementInteraction {
|
|
60
|
+
/**
|
|
61
|
+
* @param {Answerable<PageElement>} target
|
|
62
|
+
* The element to be right-clicked on
|
|
63
|
+
*/
|
|
64
|
+
constructor(target) {
|
|
65
|
+
super((0, io_1.formatted) `#actor right-clicks on ${target}`);
|
|
66
|
+
this.target = target;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @desc
|
|
70
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
71
|
+
*
|
|
72
|
+
* @param {Answerable<PageElement>} target
|
|
73
|
+
* The element to be right-clicked on
|
|
74
|
+
*
|
|
75
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
76
|
+
*/
|
|
77
|
+
static on(target) {
|
|
78
|
+
return new RightClick(target);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @desc
|
|
82
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
83
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
84
|
+
*
|
|
85
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
86
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
87
|
+
*
|
|
88
|
+
* @returns {PromiseLike<void>}
|
|
89
|
+
*
|
|
90
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
91
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
92
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
93
|
+
*/
|
|
94
|
+
async performAs(actor) {
|
|
95
|
+
const element = await this.resolve(actor, this.target);
|
|
96
|
+
return element.rightClick();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.RightClick = RightClick;
|
|
100
|
+
//# sourceMappingURL=RightClick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RightClick.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/RightClick.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAGrD,qEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAa,UAAW,SAAQ,+CAAsB;IAclD;;;OAGG;IACH,YAA6B,MAA+B;QACxD,KAAK,CAAC,IAAA,cAAS,EAAC,0BAA2B,MAAO,EAAE,CAAC,CAAC;QAD7B,WAAM,GAAN,MAAM,CAAyB;IAE5D,CAAC;IAnBD;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,CAAC,MAA+B;QACrC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAUD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAAS,CAAC,KAAuC;QACnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;CACJ;AAxCD,gCAwCC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
6
|
+
* scroll until a given Web element comes into view.
|
|
7
|
+
*
|
|
8
|
+
* @example <caption>Example widget</caption>
|
|
9
|
+
* <!--
|
|
10
|
+
* an element somewhere at the bottom of the page,
|
|
11
|
+
* outside of the visible area
|
|
12
|
+
* -->
|
|
13
|
+
* <input type="submit" id="submit" />
|
|
14
|
+
*
|
|
15
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
16
|
+
* import { Target } from '@serenity-js/protractor';
|
|
17
|
+
* import { by } from 'protractor';
|
|
18
|
+
*
|
|
19
|
+
* class Form {
|
|
20
|
+
* static submitButton = Target.the('submit button')
|
|
21
|
+
* .located(by.id('submit'));
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @example <caption>Scrolling to element</caption>
|
|
25
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
26
|
+
* import { Ensure } from '@serenity-js/assertions';
|
|
27
|
+
* import { BrowseTheWeb, Scroll, isVisible } from '@serenity-js/protractor';
|
|
28
|
+
* import { protractor } from 'protractor';
|
|
29
|
+
*
|
|
30
|
+
* actorCalled('Sara')
|
|
31
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
32
|
+
* .attemptsTo(
|
|
33
|
+
* Scroll.to(Form.submitButton),
|
|
34
|
+
* Ensure.that(Form.submitButton, isVisible()),
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* @see {@link BrowseTheWeb}
|
|
38
|
+
* @see {@link Target}
|
|
39
|
+
* @see {@link isVisible}
|
|
40
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
41
|
+
*
|
|
42
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
43
|
+
*/
|
|
44
|
+
export declare class Scroll extends Interaction {
|
|
45
|
+
private readonly target;
|
|
46
|
+
/**
|
|
47
|
+
* @desc
|
|
48
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
49
|
+
*
|
|
50
|
+
* @param {Answerable<PageElement>} target
|
|
51
|
+
* The element to be scroll to
|
|
52
|
+
*
|
|
53
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
54
|
+
*/
|
|
55
|
+
static to(target: Answerable<PageElement>): Scroll;
|
|
56
|
+
/**
|
|
57
|
+
* @param {Answerable<PageElement>} target
|
|
58
|
+
* The element to be scroll to
|
|
59
|
+
*/
|
|
60
|
+
constructor(target: Answerable<PageElement>);
|
|
61
|
+
/**
|
|
62
|
+
* @desc
|
|
63
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
64
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
65
|
+
*
|
|
66
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
67
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
68
|
+
*
|
|
69
|
+
* @returns {PromiseLike<void>}
|
|
70
|
+
*
|
|
71
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
72
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
73
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
74
|
+
*/
|
|
75
|
+
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* @desc
|
|
78
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
79
|
+
*
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
toString(): string;
|
|
83
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scroll = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
9
|
+
* scroll until a given Web element comes into view.
|
|
10
|
+
*
|
|
11
|
+
* @example <caption>Example widget</caption>
|
|
12
|
+
* <!--
|
|
13
|
+
* an element somewhere at the bottom of the page,
|
|
14
|
+
* outside of the visible area
|
|
15
|
+
* -->
|
|
16
|
+
* <input type="submit" id="submit" />
|
|
17
|
+
*
|
|
18
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
19
|
+
* import { Target } from '@serenity-js/protractor';
|
|
20
|
+
* import { by } from 'protractor';
|
|
21
|
+
*
|
|
22
|
+
* class Form {
|
|
23
|
+
* static submitButton = Target.the('submit button')
|
|
24
|
+
* .located(by.id('submit'));
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @example <caption>Scrolling to element</caption>
|
|
28
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
29
|
+
* import { Ensure } from '@serenity-js/assertions';
|
|
30
|
+
* import { BrowseTheWeb, Scroll, isVisible } from '@serenity-js/protractor';
|
|
31
|
+
* import { protractor } from 'protractor';
|
|
32
|
+
*
|
|
33
|
+
* actorCalled('Sara')
|
|
34
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
35
|
+
* .attemptsTo(
|
|
36
|
+
* Scroll.to(Form.submitButton),
|
|
37
|
+
* Ensure.that(Form.submitButton, isVisible()),
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* @see {@link BrowseTheWeb}
|
|
41
|
+
* @see {@link Target}
|
|
42
|
+
* @see {@link isVisible}
|
|
43
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
44
|
+
*
|
|
45
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
46
|
+
*/
|
|
47
|
+
class Scroll extends core_1.Interaction {
|
|
48
|
+
/**
|
|
49
|
+
* @param {Answerable<PageElement>} target
|
|
50
|
+
* The element to be scroll to
|
|
51
|
+
*/
|
|
52
|
+
constructor(target) {
|
|
53
|
+
super();
|
|
54
|
+
this.target = target;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @desc
|
|
58
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
59
|
+
*
|
|
60
|
+
* @param {Answerable<PageElement>} target
|
|
61
|
+
* The element to be scroll to
|
|
62
|
+
*
|
|
63
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
64
|
+
*/
|
|
65
|
+
static to(target) {
|
|
66
|
+
return new Scroll(target);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @desc
|
|
70
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
71
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
72
|
+
*
|
|
73
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
74
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
75
|
+
*
|
|
76
|
+
* @returns {PromiseLike<void>}
|
|
77
|
+
*
|
|
78
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
79
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
80
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
81
|
+
*/
|
|
82
|
+
async performAs(actor) {
|
|
83
|
+
const target = await actor.answer(this.target);
|
|
84
|
+
return target.scrollIntoView();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @desc
|
|
88
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
89
|
+
*
|
|
90
|
+
* @returns {string}
|
|
91
|
+
*/
|
|
92
|
+
toString() {
|
|
93
|
+
return (0, io_1.formatted) `#actor scrolls to ${this.target}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.Scroll = Scroll;
|
|
97
|
+
//# sourceMappingURL=Scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scroll.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Scroll.ts"],"names":[],"mappings":";;;AAAA,4CAA6F;AAC7F,iDAAqD;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,MAAO,SAAQ,kBAAW;IAenC;;;OAGG;IACH,YAA6B,MAA+B;QACxD,KAAK,EAAE,CAAC;QADiB,WAAM,GAAN,MAAM,CAAyB;IAE5D,CAAC;IAnBD;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,CAAC,MAA+B;QACrC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAUD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAAS,CAAC,KAAuC;QACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE/C,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAA,cAAS,EAAC,qBAAsB,IAAI,CAAC,MAAO,EAAE,CAAC;IAC1D,CAAC;CACJ;AApDD,wBAoDC"}
|