@serenity-js/webdriverio 2.32.4 → 3.0.0-rc.2
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 +70 -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 +18 -28
- 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,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Enter = void 0;
|
|
4
|
-
const io_1 = require("@serenity-js/core/lib/io");
|
|
5
|
-
const WebElementInteraction_1 = require("./WebElementInteraction");
|
|
6
|
-
/**
|
|
7
|
-
* @desc
|
|
8
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
9
|
-
* enter a value into a [form `input`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) field.
|
|
10
|
-
*
|
|
11
|
-
* @example <caption>Example widget</caption>
|
|
12
|
-
* <form>
|
|
13
|
-
* <input type="text" name="example" id="example" />
|
|
14
|
-
* </form>
|
|
15
|
-
*
|
|
16
|
-
* @example <caption>Lean Page Object describing the widget</caption>
|
|
17
|
-
* import { by, Target } from '@serenity-js/webdriverio';
|
|
18
|
-
*
|
|
19
|
-
* class Form {
|
|
20
|
-
* static exampleInput = Target.the('example input')
|
|
21
|
-
* .located(by.id('example'));
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* @example <caption>Entering the value into a form field</caption>
|
|
25
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
26
|
-
* import { BrowseTheWeb, Enter } from '@serenity-js/webdriverio';
|
|
27
|
-
*
|
|
28
|
-
* actorCalled('Esme')
|
|
29
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
30
|
-
* .attemptsTo(
|
|
31
|
-
* Enter.theValue('Hello world!').into(Form.exampleInput),
|
|
32
|
-
* );
|
|
33
|
-
*
|
|
34
|
-
* @see {@link Target}
|
|
35
|
-
*
|
|
36
|
-
* @extends {WebElementInteraction}
|
|
37
|
-
*/
|
|
38
|
-
class Enter extends WebElementInteraction_1.WebElementInteraction {
|
|
39
|
-
/**
|
|
40
|
-
* @param {Array<Answerable<string | number | string[] | number[]>>} value
|
|
41
|
-
* The value to be entered
|
|
42
|
-
*
|
|
43
|
-
* @param {Answerable<Element<'async'>>} field
|
|
44
|
-
* The field to enter the value into
|
|
45
|
-
*/
|
|
46
|
-
constructor(value, field /* todo | Question<AlertPromise> | AlertPromise */) {
|
|
47
|
-
super((0, io_1.formatted) `#actor enters ${value.join(', ')} into ${field}`);
|
|
48
|
-
this.value = value;
|
|
49
|
-
this.field = field;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @desc
|
|
53
|
-
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
54
|
-
*
|
|
55
|
-
* @param {Array<Answerable<string | number | string[] | number[]>>} value
|
|
56
|
-
* The value to be entered
|
|
57
|
-
*
|
|
58
|
-
* @returns {EnterBuilder}
|
|
59
|
-
*/
|
|
60
|
-
static theValue(...value) {
|
|
61
|
-
return {
|
|
62
|
-
into: (field /* todo Question<AlertPromise> | AlertPromise */) => new Enter(value, field),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @desc
|
|
67
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
68
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
69
|
-
*
|
|
70
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
71
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
72
|
-
*
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*
|
|
75
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
76
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
77
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
78
|
-
*/
|
|
79
|
-
async performAs(actor) {
|
|
80
|
-
const values = await Promise.all(this.value.map(part => actor.answer(part)));
|
|
81
|
-
const field = await this.resolve(actor, this.field);
|
|
82
|
-
// addValue rather than setValue so that the behaviour is consistent with Selenium sendKeys
|
|
83
|
-
return field.addValue(values.flat());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.Enter = Enter;
|
|
87
|
-
//# sourceMappingURL=Enter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Enter.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Enter.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAIrD,mEAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAa,KAAM,SAAQ,6CAAqB;IAkB5C;;;;;;OAMG;IACH,YACqB,KAA+D,EAC/D,KAAmC,CAAC,kDAAkD;QAEvG,KAAK,CAAC,IAAA,cAAS,EAAC,iBAAkB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAE,SAAU,KAAM,EAAE,CAAC,CAAC;QAHtD,UAAK,GAAL,KAAK,CAA0D;QAC/D,UAAK,GAAL,KAAK,CAA8B;IAGxD,CAAC;IA5BD;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,KAA+D;QAC9E,OAAO;YACH,IAAI,EAAE,CAAC,KAAmC,CAAE,gDAAgD,EAAE,EAAE,CAC5F,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;SAC9B,CAAC;IACN,CAAC;IAgBD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAAS,CAAC,KAAuC;QACnD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7E,MAAM,KAAK,GAAI,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAErD,2FAA2F;QAC3F,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;CACJ;AArDD,sBAqDC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Answerable, Interaction } from '@serenity-js/core';
|
|
2
|
-
import { Element } from 'webdriverio';
|
|
3
|
-
/**
|
|
4
|
-
* @desc
|
|
5
|
-
* Fluent interface to make the instantiation of
|
|
6
|
-
* the {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
7
|
-
* to {@link Enter} more readable.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link Enter}
|
|
10
|
-
*
|
|
11
|
-
* @interface
|
|
12
|
-
*/
|
|
13
|
-
export interface EnterBuilder {
|
|
14
|
-
/**
|
|
15
|
-
* @desc
|
|
16
|
-
* Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
17
|
-
* to {@link Enter}.
|
|
18
|
-
*
|
|
19
|
-
* @param {Answerable<Element<'async'>>} field
|
|
20
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
21
|
-
*
|
|
22
|
-
* @see {@link Target}
|
|
23
|
-
*/
|
|
24
|
-
into: (field: Answerable<Element<'async'>>) => Interaction;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnterBuilder.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/EnterBuilder.ts"],"names":[],"mappings":""}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { Answerable, AnswersQuestions, CollectsArtifacts, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
-
/**
|
|
3
|
-
* @desc
|
|
4
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
5
|
-
* execute a script within the context of the current browser window.
|
|
6
|
-
*
|
|
7
|
-
* Please see the tests below for usage examples.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link LastScriptExecution.result}
|
|
10
|
-
*/
|
|
11
|
-
export declare class ExecuteScript {
|
|
12
|
-
/**
|
|
13
|
-
* @desc
|
|
14
|
-
* Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
15
|
-
* configured to load a script from `sourceUrl`.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} sourceUrl
|
|
18
|
-
* The URL to load the script from
|
|
19
|
-
*
|
|
20
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
21
|
-
*/
|
|
22
|
-
static from(sourceUrl: string): Interaction;
|
|
23
|
-
/**
|
|
24
|
-
* @desc
|
|
25
|
-
* Schedules a command to execute asynchronous JavaScript in the context of the currently selected frame or window.
|
|
26
|
-
* The script fragment will be executed as the body of an anonymous function.
|
|
27
|
-
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
28
|
-
* into the target window.
|
|
29
|
-
*
|
|
30
|
-
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
31
|
-
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string`
|
|
32
|
-
* or {@link Target} (`Answerable<Element<'async'>>`).
|
|
33
|
-
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
34
|
-
* to the types previously mentioned.
|
|
35
|
-
*
|
|
36
|
-
* Unlike executing synchronous JavaScript with {@link ExecuteScript#sync},
|
|
37
|
-
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
38
|
-
*
|
|
39
|
-
* This callback will always be injected into the executed function as the last argument,
|
|
40
|
-
* and thus may be referenced with `arguments[arguments.length - 1]`.
|
|
41
|
-
*
|
|
42
|
-
* If the script invokes the `callback` with a return value, this will be made available
|
|
43
|
-
* via the {@link LastScriptExecution.result}.
|
|
44
|
-
*
|
|
45
|
-
* **Please note** that in order to signal an error in the `script` you need to throw an {@link Error}
|
|
46
|
-
* instead of passing it to the callback function.
|
|
47
|
-
*
|
|
48
|
-
* @example <caption>Executing an async script</caption>
|
|
49
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
50
|
-
*
|
|
51
|
-
* actor.attemptsTo(
|
|
52
|
-
* ExecuteScript.async(`
|
|
53
|
-
* var callback = arguments[arguments.length - 1];
|
|
54
|
-
*
|
|
55
|
-
* // do stuff
|
|
56
|
-
*
|
|
57
|
-
* callback(result)
|
|
58
|
-
* `)
|
|
59
|
-
* );
|
|
60
|
-
*
|
|
61
|
-
* @example <caption>Passing arguments to an async script</caption>
|
|
62
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
63
|
-
*
|
|
64
|
-
* actor.attemptsTo(
|
|
65
|
-
* ExecuteScript.async(`
|
|
66
|
-
* var name = arguments[0];
|
|
67
|
-
* var age = arguments[1];
|
|
68
|
-
* var callback = arguments[arguments.length - 1];
|
|
69
|
-
*
|
|
70
|
-
* // do stuff
|
|
71
|
-
*
|
|
72
|
-
* callback(result)
|
|
73
|
-
* `).withArguments('Bob', 24)
|
|
74
|
-
* );
|
|
75
|
-
*
|
|
76
|
-
* @example <caption>Passing Target arguments to an async script</caption>
|
|
77
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
78
|
-
*
|
|
79
|
-
* actor.attemptsTo(
|
|
80
|
-
* ExecuteScript.async(`
|
|
81
|
-
* var header = arguments[0]; // Target gets converted to a WebElement
|
|
82
|
-
* var callback = arguments[arguments.length - 1];
|
|
83
|
-
*
|
|
84
|
-
* callback(header.innerText)
|
|
85
|
-
* `).withArguments(Target.the('header').located(by.css('h1')))
|
|
86
|
-
* );
|
|
87
|
-
*
|
|
88
|
-
* @example <caption>Executing async script as function</caption>
|
|
89
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
90
|
-
*
|
|
91
|
-
* actor.attemptsTo(
|
|
92
|
-
* ExecuteScript.async(function getText(header, callback) {
|
|
93
|
-
* callback(header.innerText)
|
|
94
|
-
* }).withArguments(Target.the('header').located(by.css('h1')))
|
|
95
|
-
* );
|
|
96
|
-
*
|
|
97
|
-
* @param {string | Function} script
|
|
98
|
-
* The script to be executed
|
|
99
|
-
*
|
|
100
|
-
* @returns {ExecuteScriptWithArguments}
|
|
101
|
-
*
|
|
102
|
-
* @see {@link LastScriptExecution.result}
|
|
103
|
-
*/
|
|
104
|
-
static async(script: string | Function): ExecuteScriptWithArguments;
|
|
105
|
-
/**
|
|
106
|
-
* @desc
|
|
107
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
108
|
-
* execute a synchronous script in the context of the currently selected frame or window.
|
|
109
|
-
*
|
|
110
|
-
* If the script returns a value, it will be made available via {@link LastScriptExecution.result}.
|
|
111
|
-
*
|
|
112
|
-
* @example <caption>Executing a sync script as string and reading the result</caption>
|
|
113
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
114
|
-
* import { BrowseTheWeb, ExecuteScript, LastScriptExecution } from '@serenity-js/webdriverio';
|
|
115
|
-
* import { Ensure, includes } from '@serenity-js/assertions';
|
|
116
|
-
*
|
|
117
|
-
* actorCalled('Joseph')
|
|
118
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
119
|
-
* .attemptsTo(
|
|
120
|
-
* ExecuteScript.sync('return navigator.userAgent'),
|
|
121
|
-
* Ensure.that(LastScriptExecution.result<string>(), includes('Chrome')),
|
|
122
|
-
* );
|
|
123
|
-
*
|
|
124
|
-
* @example <caption>Executing a sync script as function and reading the result</caption>
|
|
125
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
126
|
-
* import { by, BrowseTheWeb, Enter, ExecuteScript, LastScriptExecution, Target } from '@serenity-js/webdriverio';
|
|
127
|
-
*
|
|
128
|
-
* const someOfferField = Target.the('offer code').located(by.id('offer-code'));
|
|
129
|
-
* const applyOfferCodeField = Target.the('apply offer field').located(by.id('apply-offer-code'));
|
|
130
|
-
*
|
|
131
|
-
* actorCalled('Joseph')
|
|
132
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
133
|
-
* .attemptsTo(
|
|
134
|
-
* // inject JavaScript to read some property of an element
|
|
135
|
-
* ExecuteScript.sync(function getValue(element) {
|
|
136
|
-
* return element.value;
|
|
137
|
-
* }).withArguments(someOfferField),
|
|
138
|
-
*
|
|
139
|
-
* // use LastScriptExecution.result() to read the value
|
|
140
|
-
* // returned from the injected script
|
|
141
|
-
* // and pass it to another interaction
|
|
142
|
-
* Enter.theValue(LastScriptExecution.result<string>()).into(applyOfferCodeField),
|
|
143
|
-
* );
|
|
144
|
-
*
|
|
145
|
-
* @param {string | Function} script
|
|
146
|
-
* The script to be executed
|
|
147
|
-
*
|
|
148
|
-
* @returns {ExecuteScriptWithArguments}
|
|
149
|
-
*
|
|
150
|
-
* @see {@link LastScriptExecution.result}
|
|
151
|
-
*/
|
|
152
|
-
static sync(script: string | Function): ExecuteScriptWithArguments;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* @desc
|
|
156
|
-
* Allows for a script to be executed to be parametrised.
|
|
157
|
-
*
|
|
158
|
-
* **Please note** that the arguments can be both synchronous and asynchronous {@link @serenity-js/core/lib/screenplay~Question}s
|
|
159
|
-
* as well as regular static values.
|
|
160
|
-
*
|
|
161
|
-
* @abstract
|
|
162
|
-
*
|
|
163
|
-
* @see {@link ExecuteScript}
|
|
164
|
-
*
|
|
165
|
-
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
166
|
-
*/
|
|
167
|
-
export declare abstract class ExecuteScriptWithArguments extends Interaction {
|
|
168
|
-
protected readonly script: string | Function;
|
|
169
|
-
protected readonly args: Array<Answerable<any>>;
|
|
170
|
-
/**
|
|
171
|
-
* @param {string | Function} script
|
|
172
|
-
* The script to be executed
|
|
173
|
-
*
|
|
174
|
-
* @param {Array<Answerable<any>>} args
|
|
175
|
-
* Arguments to parametrise the script with
|
|
176
|
-
*/
|
|
177
|
-
constructor(script: string | Function, // eslint-disable-line @typescript-eslint/ban-types
|
|
178
|
-
args?: Array<Answerable<any>>);
|
|
179
|
-
/**
|
|
180
|
-
* @desc
|
|
181
|
-
* Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
182
|
-
* to {@link Enter}.
|
|
183
|
-
*
|
|
184
|
-
* @param {...Array<Answerable<any>>} args
|
|
185
|
-
* Arguments to parametrise the script with
|
|
186
|
-
*
|
|
187
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
188
|
-
*/
|
|
189
|
-
abstract withArguments(...args: Array<Answerable<any>>): Interaction;
|
|
190
|
-
/**
|
|
191
|
-
* @desc
|
|
192
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
193
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
194
|
-
*
|
|
195
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
196
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
197
|
-
*
|
|
198
|
-
* @returns {PromiseLike<void>}
|
|
199
|
-
*
|
|
200
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
201
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
202
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
203
|
-
*/
|
|
204
|
-
performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): PromiseLike<void>;
|
|
205
|
-
protected abstract executeAs(actor: UsesAbilities & AnswersQuestions, args: any[]): Promise<any>;
|
|
206
|
-
}
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExecuteScriptWithArguments = exports.ExecuteScript = void 0;
|
|
4
|
-
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
|
-
const model_1 = require("@serenity-js/core/lib/model");
|
|
7
|
-
const abilities_1 = require("../abilities");
|
|
8
|
-
/**
|
|
9
|
-
* @desc
|
|
10
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
11
|
-
* execute a script within the context of the current browser window.
|
|
12
|
-
*
|
|
13
|
-
* Please see the tests below for usage examples.
|
|
14
|
-
*
|
|
15
|
-
* @see {@link LastScriptExecution.result}
|
|
16
|
-
*/
|
|
17
|
-
class ExecuteScript {
|
|
18
|
-
/**
|
|
19
|
-
* @desc
|
|
20
|
-
* Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
21
|
-
* configured to load a script from `sourceUrl`.
|
|
22
|
-
*
|
|
23
|
-
* @param {string} sourceUrl
|
|
24
|
-
* The URL to load the script from
|
|
25
|
-
*
|
|
26
|
-
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
27
|
-
*/
|
|
28
|
-
static from(sourceUrl) {
|
|
29
|
-
return new ExecuteScriptFromUrl(sourceUrl);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @desc
|
|
33
|
-
* Schedules a command to execute asynchronous JavaScript in the context of the currently selected frame or window.
|
|
34
|
-
* The script fragment will be executed as the body of an anonymous function.
|
|
35
|
-
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
36
|
-
* into the target window.
|
|
37
|
-
*
|
|
38
|
-
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
39
|
-
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string`
|
|
40
|
-
* or {@link Target} (`Answerable<Element<'async'>>`).
|
|
41
|
-
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
42
|
-
* to the types previously mentioned.
|
|
43
|
-
*
|
|
44
|
-
* Unlike executing synchronous JavaScript with {@link ExecuteScript#sync},
|
|
45
|
-
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
46
|
-
*
|
|
47
|
-
* This callback will always be injected into the executed function as the last argument,
|
|
48
|
-
* and thus may be referenced with `arguments[arguments.length - 1]`.
|
|
49
|
-
*
|
|
50
|
-
* If the script invokes the `callback` with a return value, this will be made available
|
|
51
|
-
* via the {@link LastScriptExecution.result}.
|
|
52
|
-
*
|
|
53
|
-
* **Please note** that in order to signal an error in the `script` you need to throw an {@link Error}
|
|
54
|
-
* instead of passing it to the callback function.
|
|
55
|
-
*
|
|
56
|
-
* @example <caption>Executing an async script</caption>
|
|
57
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
58
|
-
*
|
|
59
|
-
* actor.attemptsTo(
|
|
60
|
-
* ExecuteScript.async(`
|
|
61
|
-
* var callback = arguments[arguments.length - 1];
|
|
62
|
-
*
|
|
63
|
-
* // do stuff
|
|
64
|
-
*
|
|
65
|
-
* callback(result)
|
|
66
|
-
* `)
|
|
67
|
-
* );
|
|
68
|
-
*
|
|
69
|
-
* @example <caption>Passing arguments to an async script</caption>
|
|
70
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
71
|
-
*
|
|
72
|
-
* actor.attemptsTo(
|
|
73
|
-
* ExecuteScript.async(`
|
|
74
|
-
* var name = arguments[0];
|
|
75
|
-
* var age = arguments[1];
|
|
76
|
-
* var callback = arguments[arguments.length - 1];
|
|
77
|
-
*
|
|
78
|
-
* // do stuff
|
|
79
|
-
*
|
|
80
|
-
* callback(result)
|
|
81
|
-
* `).withArguments('Bob', 24)
|
|
82
|
-
* );
|
|
83
|
-
*
|
|
84
|
-
* @example <caption>Passing Target arguments to an async script</caption>
|
|
85
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
86
|
-
*
|
|
87
|
-
* actor.attemptsTo(
|
|
88
|
-
* ExecuteScript.async(`
|
|
89
|
-
* var header = arguments[0]; // Target gets converted to a WebElement
|
|
90
|
-
* var callback = arguments[arguments.length - 1];
|
|
91
|
-
*
|
|
92
|
-
* callback(header.innerText)
|
|
93
|
-
* `).withArguments(Target.the('header').located(by.css('h1')))
|
|
94
|
-
* );
|
|
95
|
-
*
|
|
96
|
-
* @example <caption>Executing async script as function</caption>
|
|
97
|
-
* import { ExecuteScript } from '@serenity-js/webdriverio';
|
|
98
|
-
*
|
|
99
|
-
* actor.attemptsTo(
|
|
100
|
-
* ExecuteScript.async(function getText(header, callback) {
|
|
101
|
-
* callback(header.innerText)
|
|
102
|
-
* }).withArguments(Target.the('header').located(by.css('h1')))
|
|
103
|
-
* );
|
|
104
|
-
*
|
|
105
|
-
* @param {string | Function} script
|
|
106
|
-
* The script to be executed
|
|
107
|
-
*
|
|
108
|
-
* @returns {ExecuteScriptWithArguments}
|
|
109
|
-
*
|
|
110
|
-
* @see {@link LastScriptExecution.result}
|
|
111
|
-
*/
|
|
112
|
-
static async(script) {
|
|
113
|
-
return new ExecuteAsynchronousScript(script);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* @desc
|
|
117
|
-
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
118
|
-
* execute a synchronous script in the context of the currently selected frame or window.
|
|
119
|
-
*
|
|
120
|
-
* If the script returns a value, it will be made available via {@link LastScriptExecution.result}.
|
|
121
|
-
*
|
|
122
|
-
* @example <caption>Executing a sync script as string and reading the result</caption>
|
|
123
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
124
|
-
* import { BrowseTheWeb, ExecuteScript, LastScriptExecution } from '@serenity-js/webdriverio';
|
|
125
|
-
* import { Ensure, includes } from '@serenity-js/assertions';
|
|
126
|
-
*
|
|
127
|
-
* actorCalled('Joseph')
|
|
128
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
129
|
-
* .attemptsTo(
|
|
130
|
-
* ExecuteScript.sync('return navigator.userAgent'),
|
|
131
|
-
* Ensure.that(LastScriptExecution.result<string>(), includes('Chrome')),
|
|
132
|
-
* );
|
|
133
|
-
*
|
|
134
|
-
* @example <caption>Executing a sync script as function and reading the result</caption>
|
|
135
|
-
* import { actorCalled } from '@serenity-js/core';
|
|
136
|
-
* import { by, BrowseTheWeb, Enter, ExecuteScript, LastScriptExecution, Target } from '@serenity-js/webdriverio';
|
|
137
|
-
*
|
|
138
|
-
* const someOfferField = Target.the('offer code').located(by.id('offer-code'));
|
|
139
|
-
* const applyOfferCodeField = Target.the('apply offer field').located(by.id('apply-offer-code'));
|
|
140
|
-
*
|
|
141
|
-
* actorCalled('Joseph')
|
|
142
|
-
* .whoCan(BrowseTheWeb.using(browser))
|
|
143
|
-
* .attemptsTo(
|
|
144
|
-
* // inject JavaScript to read some property of an element
|
|
145
|
-
* ExecuteScript.sync(function getValue(element) {
|
|
146
|
-
* return element.value;
|
|
147
|
-
* }).withArguments(someOfferField),
|
|
148
|
-
*
|
|
149
|
-
* // use LastScriptExecution.result() to read the value
|
|
150
|
-
* // returned from the injected script
|
|
151
|
-
* // and pass it to another interaction
|
|
152
|
-
* Enter.theValue(LastScriptExecution.result<string>()).into(applyOfferCodeField),
|
|
153
|
-
* );
|
|
154
|
-
*
|
|
155
|
-
* @param {string | Function} script
|
|
156
|
-
* The script to be executed
|
|
157
|
-
*
|
|
158
|
-
* @returns {ExecuteScriptWithArguments}
|
|
159
|
-
*
|
|
160
|
-
* @see {@link LastScriptExecution.result}
|
|
161
|
-
*/
|
|
162
|
-
static sync(script) {
|
|
163
|
-
return new ExecuteSynchronousScript(script);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exports.ExecuteScript = ExecuteScript;
|
|
167
|
-
/**
|
|
168
|
-
* @desc
|
|
169
|
-
* Allows for a script to be executed to be parametrised.
|
|
170
|
-
*
|
|
171
|
-
* **Please note** that the arguments can be both synchronous and asynchronous {@link @serenity-js/core/lib/screenplay~Question}s
|
|
172
|
-
* as well as regular static values.
|
|
173
|
-
*
|
|
174
|
-
* @abstract
|
|
175
|
-
*
|
|
176
|
-
* @see {@link ExecuteScript}
|
|
177
|
-
*
|
|
178
|
-
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
179
|
-
*/
|
|
180
|
-
class ExecuteScriptWithArguments extends core_1.Interaction {
|
|
181
|
-
/**
|
|
182
|
-
* @param {string | Function} script
|
|
183
|
-
* The script to be executed
|
|
184
|
-
*
|
|
185
|
-
* @param {Array<Answerable<any>>} args
|
|
186
|
-
* Arguments to parametrise the script with
|
|
187
|
-
*/
|
|
188
|
-
constructor(script, // eslint-disable-line @typescript-eslint/ban-types
|
|
189
|
-
args = []) {
|
|
190
|
-
super();
|
|
191
|
-
this.script = script;
|
|
192
|
-
this.args = args;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* @desc
|
|
196
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
197
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
198
|
-
*
|
|
199
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
200
|
-
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
201
|
-
*
|
|
202
|
-
* @returns {PromiseLike<void>}
|
|
203
|
-
*
|
|
204
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
205
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
206
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
207
|
-
*/
|
|
208
|
-
performAs(actor) {
|
|
209
|
-
return Promise.all(this.args.map(arg => actor.answer(arg)))
|
|
210
|
-
.then(args => this.executeAs(actor, args))
|
|
211
|
-
.then(() => actor.collect(model_1.TextData.fromJSON({
|
|
212
|
-
contentType: 'text/javascript;charset=UTF-8',
|
|
213
|
-
data: this.script.toString(),
|
|
214
|
-
}), new model_1.Name('Script source')));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
exports.ExecuteScriptWithArguments = ExecuteScriptWithArguments;
|
|
218
|
-
/**
|
|
219
|
-
* @package
|
|
220
|
-
*/
|
|
221
|
-
class ExecuteAsynchronousScript extends ExecuteScriptWithArguments {
|
|
222
|
-
withArguments(...args) {
|
|
223
|
-
return new ExecuteAsynchronousScript(this.script, args);
|
|
224
|
-
}
|
|
225
|
-
executeAs(actor, args) {
|
|
226
|
-
return abilities_1.BrowseTheWeb.as(actor).executeAsyncScript(this.script, ...args); // todo: fix types
|
|
227
|
-
}
|
|
228
|
-
toString() {
|
|
229
|
-
return this.args.length > 0
|
|
230
|
-
? (0, io_1.formatted) `#actor executes an asynchronous script with arguments: ${this.args}`
|
|
231
|
-
: `#actor executes an asynchronous script`;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* @package
|
|
236
|
-
*
|
|
237
|
-
* https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html
|
|
238
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement
|
|
239
|
-
*/
|
|
240
|
-
class ExecuteScriptFromUrl extends core_1.Interaction {
|
|
241
|
-
constructor(sourceUrl) {
|
|
242
|
-
super();
|
|
243
|
-
this.sourceUrl = sourceUrl;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @desc
|
|
247
|
-
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
248
|
-
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
249
|
-
*
|
|
250
|
-
* @param {UsesAbilities & AnswersQuestions} actor
|
|
251
|
-
* @returns {Promise<void>}
|
|
252
|
-
*
|
|
253
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
254
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
255
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
256
|
-
*/
|
|
257
|
-
performAs(actor) {
|
|
258
|
-
return abilities_1.BrowseTheWeb.as(actor)
|
|
259
|
-
.browser.executeAsync(
|
|
260
|
-
/* istanbul ignore next */
|
|
261
|
-
function executeScriptFromUrl(sourceUrl, callback) {
|
|
262
|
-
const alreadyLoadedScripts = Array.prototype.slice
|
|
263
|
-
.call(document.querySelectorAll('script'))
|
|
264
|
-
.map(script => script.src);
|
|
265
|
-
if (~alreadyLoadedScripts.indexOf(sourceUrl)) {
|
|
266
|
-
return callback('Script from ' + sourceUrl + ' has already been loaded');
|
|
267
|
-
}
|
|
268
|
-
const script = document.createElement('script');
|
|
269
|
-
script.addEventListener('load', function () {
|
|
270
|
-
callback();
|
|
271
|
-
});
|
|
272
|
-
script.addEventListener('error', function () {
|
|
273
|
-
return callback('Couldn\'t load script from ' + sourceUrl);
|
|
274
|
-
});
|
|
275
|
-
script.src = sourceUrl;
|
|
276
|
-
script.async = true;
|
|
277
|
-
document.head.append(script);
|
|
278
|
-
}, this.sourceUrl)
|
|
279
|
-
.then(errorMessage => {
|
|
280
|
-
if (errorMessage) {
|
|
281
|
-
throw new core_1.LogicError(errorMessage);
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* @desc
|
|
287
|
-
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
288
|
-
*
|
|
289
|
-
* @returns {string}
|
|
290
|
-
*/
|
|
291
|
-
toString() {
|
|
292
|
-
return `#actor executes a script from ${this.sourceUrl}`;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* @package
|
|
297
|
-
*/
|
|
298
|
-
class ExecuteSynchronousScript extends ExecuteScriptWithArguments {
|
|
299
|
-
withArguments(...args) {
|
|
300
|
-
return new ExecuteSynchronousScript(this.script, args);
|
|
301
|
-
}
|
|
302
|
-
executeAs(actor, args) {
|
|
303
|
-
return abilities_1.BrowseTheWeb.as(actor).executeScript(this.script, ...args); // todo fix type
|
|
304
|
-
}
|
|
305
|
-
toString() {
|
|
306
|
-
return this.args.length > 0
|
|
307
|
-
? (0, io_1.formatted) `#actor executes a synchronous script with arguments: ${this.args}`
|
|
308
|
-
: `#actor executes a synchronous script`;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
//# sourceMappingURL=ExecuteScript.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExecuteScript.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/ExecuteScript.ts"],"names":[],"mappings":";;;AAAA,4CAA4H;AAC5H,iDAAqD;AACrD,uDAA6D;AAE7D,4CAA4C;AAE5C;;;;;;;;GAQG;AACH,MAAa,aAAa;IAEtB;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,SAAiB;QACzB,OAAO,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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