@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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Hover = 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
|
+
* hover the mouse pointer over a given Web element.
|
|
10
|
+
*
|
|
11
|
+
* @example <caption>Example widget</caption>
|
|
12
|
+
* <a data-test="example-link"
|
|
13
|
+
* class="off"
|
|
14
|
+
* onmouseover="this.className='on';"
|
|
15
|
+
* onmouseout="this.className='off';"
|
|
16
|
+
* href="/">hover over me</a>
|
|
17
|
+
*
|
|
18
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
19
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
20
|
+
*
|
|
21
|
+
* class Example {
|
|
22
|
+
* static link = Target.the('example link')
|
|
23
|
+
* .located(by.css('[data-test="example-link"]'));
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @example <caption>Hovering over an element</caption>
|
|
27
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
28
|
+
* import { BrowseTheWeb, Hover, CssClasses } from '@serenity-js/webdriverio';
|
|
29
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
30
|
+
*
|
|
31
|
+
* actorCalled('Hank')
|
|
32
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
33
|
+
* .attemptsTo(
|
|
34
|
+
* Ensure.that(CssClasses.of(Example.link), equals([ 'off' ])),
|
|
35
|
+
*
|
|
36
|
+
* Hover.over(Example.link),
|
|
37
|
+
* Ensure.that(CssClasses.of(Example.link), equals([ 'on' ])),
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* @see {@link BrowseTheWeb}
|
|
41
|
+
* @see {@link Target}
|
|
42
|
+
* @see {@link CssClasses}
|
|
43
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
44
|
+
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
45
|
+
*
|
|
46
|
+
* @extends {ElementInteraction}
|
|
47
|
+
*/
|
|
48
|
+
class Hover extends PageElementInteraction_1.PageElementInteraction {
|
|
49
|
+
/**
|
|
50
|
+
* @param {Answerable<PageElement>} target
|
|
51
|
+
* The element to be hovered over
|
|
52
|
+
*/
|
|
53
|
+
constructor(target) {
|
|
54
|
+
super((0, io_1.formatted) `#actor hovers the mouse over ${target}`);
|
|
55
|
+
this.target = target;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @desc
|
|
59
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
60
|
+
*
|
|
61
|
+
* @param {Answerable<PageElement>} target
|
|
62
|
+
* The element to be hovered over
|
|
63
|
+
*
|
|
64
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
65
|
+
*/
|
|
66
|
+
static over(target) {
|
|
67
|
+
return new Hover(target);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @desc
|
|
71
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
72
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
73
|
+
*
|
|
74
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
75
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
76
|
+
*
|
|
77
|
+
* @returns {PromiseLike<void>}
|
|
78
|
+
*
|
|
79
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
80
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
81
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
82
|
+
*/
|
|
83
|
+
async performAs(actor) {
|
|
84
|
+
const element = await this.resolve(actor, this.target);
|
|
85
|
+
return element.hoverOver();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.Hover = Hover;
|
|
89
|
+
//# sourceMappingURL=Hover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hover.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Hover.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAGrD,qEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAa,KAAM,SAAQ,+CAAsB;IAe7C;;;OAGG;IACH,YAA6B,MAA+B;QACxD,KAAK,CAAC,IAAA,cAAS,EAAC,gCAAiC,MAAO,EAAE,CAAC,CAAC;QADnC,WAAM,GAAN,MAAM,CAAyB;IAE5D,CAAC;IAnBD;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,CAAC,MAA+B;QACvC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,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,SAAS,EAAE,CAAC;IAC/B,CAAC;CACJ;AAzCD,sBAyCC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Answerable, Interaction } from '@serenity-js/core';
|
|
2
|
+
/**
|
|
3
|
+
* @desc
|
|
4
|
+
* Allows the {@link @serenity-js/core/lib/screenplay/actor~Actor} to navigate
|
|
5
|
+
* to a specific destination, as well as back and forth in the browser history,
|
|
6
|
+
* or reload the current page.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Navigate {
|
|
9
|
+
/**
|
|
10
|
+
* @desc
|
|
11
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
12
|
+
* to navigate to a given URL.
|
|
13
|
+
*
|
|
14
|
+
* The URL can be:
|
|
15
|
+
* - absolute, i.e. `https://example.org/search`
|
|
16
|
+
* - relative, i.e. `/search`
|
|
17
|
+
*
|
|
18
|
+
* If the URL is relative, WebdriverIO will append it to `baseUrl` specified in
|
|
19
|
+
* the [configuration file](https://webdriver.io/docs/configurationfile/).
|
|
20
|
+
*
|
|
21
|
+
* @example <caption>wdio.conf.ts</caption>
|
|
22
|
+
* export const config = {
|
|
23
|
+
* baseUrl: 'https://example.org',
|
|
24
|
+
* // ...
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
28
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
29
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
30
|
+
*
|
|
31
|
+
* actorCalled('Hannu')
|
|
32
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
33
|
+
* .attemptsTo(
|
|
34
|
+
* Navigate.to('/search'),
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* @example <caption>Navigate to an absolute URL (overrides baseUrl)</caption>
|
|
38
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
39
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
40
|
+
*
|
|
41
|
+
* actorCalled('Hannu')
|
|
42
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
43
|
+
* .attemptsTo(
|
|
44
|
+
* Navigate.to('https://mycompany.org/login'),
|
|
45
|
+
* );
|
|
46
|
+
*
|
|
47
|
+
* @param {Answerable<string>} url
|
|
48
|
+
* An absolute URL or path an {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
49
|
+
* should navigate to
|
|
50
|
+
*
|
|
51
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
52
|
+
*
|
|
53
|
+
* @see {@link BrowseTheWeb}
|
|
54
|
+
*/
|
|
55
|
+
static to(url: Answerable<string>): Interaction;
|
|
56
|
+
/**
|
|
57
|
+
* @desc
|
|
58
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
59
|
+
* navigate back one page in the joint session history of the current top-level browsing context.
|
|
60
|
+
*
|
|
61
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
62
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
63
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
64
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
65
|
+
*
|
|
66
|
+
* actorCalled('Hannu')
|
|
67
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
68
|
+
* .attemptsTo(
|
|
69
|
+
* Navigate.to('/first'),
|
|
70
|
+
* Navigate.to('/second'),
|
|
71
|
+
*
|
|
72
|
+
* Navigate.back(),
|
|
73
|
+
*
|
|
74
|
+
* Ensure.that(Website.url(), endsWith('/first')),
|
|
75
|
+
* );
|
|
76
|
+
*
|
|
77
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
78
|
+
*
|
|
79
|
+
* @see https://webdriver.io/docs/api/webdriver/#back
|
|
80
|
+
* @see {@link BrowseTheWeb}
|
|
81
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
82
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
83
|
+
*/
|
|
84
|
+
static back(): Interaction;
|
|
85
|
+
/**
|
|
86
|
+
* @desc
|
|
87
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
88
|
+
* navigate forward one page in the session history.
|
|
89
|
+
*
|
|
90
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
91
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
92
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
93
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
94
|
+
*
|
|
95
|
+
* actorCalled('Hannu')
|
|
96
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
97
|
+
* .attemptsTo(
|
|
98
|
+
* Navigate.to('/first'),
|
|
99
|
+
* Navigate.to('/second'),
|
|
100
|
+
*
|
|
101
|
+
* Navigate.back(),
|
|
102
|
+
* Navigate.forward(),
|
|
103
|
+
*
|
|
104
|
+
* Ensure.that(Website.url(), endsWith('/second')),
|
|
105
|
+
* );
|
|
106
|
+
*
|
|
107
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
108
|
+
*
|
|
109
|
+
* @see {@link BrowseTheWeb}
|
|
110
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
111
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
112
|
+
* @see https://webdriver.io/docs/api/webdriver/#forward
|
|
113
|
+
*/
|
|
114
|
+
static forward(): Interaction;
|
|
115
|
+
/**
|
|
116
|
+
* @desc
|
|
117
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
118
|
+
* reload the current page.
|
|
119
|
+
*
|
|
120
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
121
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
122
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
123
|
+
* import { Navigate, Cookie } from '@serenity-js/web';
|
|
124
|
+
* import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
|
|
125
|
+
*
|
|
126
|
+
* actorCalled('Hannu')
|
|
127
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
128
|
+
* .attemptsTo(
|
|
129
|
+
* Navigate.to('/login'),
|
|
130
|
+
* Cookie.called('session_id').delete(),
|
|
131
|
+
* Navigate.reloadPage(),
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
135
|
+
*
|
|
136
|
+
* @see {@link BrowseTheWeb}
|
|
137
|
+
* @see {@link Cookie}
|
|
138
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
139
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
140
|
+
*/
|
|
141
|
+
static reloadPage(): Interaction;
|
|
142
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Navigate = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
|
+
const abilities_1 = require("../abilities");
|
|
7
|
+
/**
|
|
8
|
+
* @desc
|
|
9
|
+
* Allows the {@link @serenity-js/core/lib/screenplay/actor~Actor} to navigate
|
|
10
|
+
* to a specific destination, as well as back and forth in the browser history,
|
|
11
|
+
* or reload the current page.
|
|
12
|
+
*/
|
|
13
|
+
class Navigate {
|
|
14
|
+
/**
|
|
15
|
+
* @desc
|
|
16
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
17
|
+
* to navigate to a given URL.
|
|
18
|
+
*
|
|
19
|
+
* The URL can be:
|
|
20
|
+
* - absolute, i.e. `https://example.org/search`
|
|
21
|
+
* - relative, i.e. `/search`
|
|
22
|
+
*
|
|
23
|
+
* If the URL is relative, WebdriverIO will append it to `baseUrl` specified in
|
|
24
|
+
* the [configuration file](https://webdriver.io/docs/configurationfile/).
|
|
25
|
+
*
|
|
26
|
+
* @example <caption>wdio.conf.ts</caption>
|
|
27
|
+
* export const config = {
|
|
28
|
+
* baseUrl: 'https://example.org',
|
|
29
|
+
* // ...
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
33
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
34
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
35
|
+
*
|
|
36
|
+
* actorCalled('Hannu')
|
|
37
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
38
|
+
* .attemptsTo(
|
|
39
|
+
* Navigate.to('/search'),
|
|
40
|
+
* );
|
|
41
|
+
*
|
|
42
|
+
* @example <caption>Navigate to an absolute URL (overrides baseUrl)</caption>
|
|
43
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
44
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
45
|
+
*
|
|
46
|
+
* actorCalled('Hannu')
|
|
47
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
48
|
+
* .attemptsTo(
|
|
49
|
+
* Navigate.to('https://mycompany.org/login'),
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* @param {Answerable<string>} url
|
|
53
|
+
* An absolute URL or path an {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
54
|
+
* should navigate to
|
|
55
|
+
*
|
|
56
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
57
|
+
*
|
|
58
|
+
* @see {@link BrowseTheWeb}
|
|
59
|
+
*/
|
|
60
|
+
static to(url) {
|
|
61
|
+
return new NavigateToUrl(url);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @desc
|
|
65
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
66
|
+
* navigate back one page in the joint session history of the current top-level browsing context.
|
|
67
|
+
*
|
|
68
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
69
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
70
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
71
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
72
|
+
*
|
|
73
|
+
* actorCalled('Hannu')
|
|
74
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
75
|
+
* .attemptsTo(
|
|
76
|
+
* Navigate.to('/first'),
|
|
77
|
+
* Navigate.to('/second'),
|
|
78
|
+
*
|
|
79
|
+
* Navigate.back(),
|
|
80
|
+
*
|
|
81
|
+
* Ensure.that(Website.url(), endsWith('/first')),
|
|
82
|
+
* );
|
|
83
|
+
*
|
|
84
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
85
|
+
*
|
|
86
|
+
* @see https://webdriver.io/docs/api/webdriver/#back
|
|
87
|
+
* @see {@link BrowseTheWeb}
|
|
88
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
89
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
90
|
+
*/
|
|
91
|
+
static back() {
|
|
92
|
+
return core_1.Interaction.where(`#actor navigates back in the browser history`, actor => abilities_1.BrowseTheWeb.as(actor).navigateBack());
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @desc
|
|
96
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
97
|
+
* navigate forward one page in the session history.
|
|
98
|
+
*
|
|
99
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
100
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
101
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
102
|
+
* import { BrowseTheWeb, Navigate } from '@serenity-js/webdriverio';
|
|
103
|
+
*
|
|
104
|
+
* actorCalled('Hannu')
|
|
105
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
106
|
+
* .attemptsTo(
|
|
107
|
+
* Navigate.to('/first'),
|
|
108
|
+
* Navigate.to('/second'),
|
|
109
|
+
*
|
|
110
|
+
* Navigate.back(),
|
|
111
|
+
* Navigate.forward(),
|
|
112
|
+
*
|
|
113
|
+
* Ensure.that(Website.url(), endsWith('/second')),
|
|
114
|
+
* );
|
|
115
|
+
*
|
|
116
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
117
|
+
*
|
|
118
|
+
* @see {@link BrowseTheWeb}
|
|
119
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
120
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
121
|
+
* @see https://webdriver.io/docs/api/webdriver/#forward
|
|
122
|
+
*/
|
|
123
|
+
static forward() {
|
|
124
|
+
return core_1.Interaction.where(`#actor navigates forward in the browser history`, actor => abilities_1.BrowseTheWeb.as(actor).navigateForward());
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @desc
|
|
128
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
129
|
+
* reload the current page.
|
|
130
|
+
*
|
|
131
|
+
* @example <caption>Navigate to path relative to baseUrl</caption>
|
|
132
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
133
|
+
* import { Ensure, endsWith } from '@serenity-js/assertions';
|
|
134
|
+
* import { Navigate, Cookie } from '@serenity-js/web';
|
|
135
|
+
* import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio';
|
|
136
|
+
*
|
|
137
|
+
* actorCalled('Hannu')
|
|
138
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser))
|
|
139
|
+
* .attemptsTo(
|
|
140
|
+
* Navigate.to('/login'),
|
|
141
|
+
* Cookie.called('session_id').delete(),
|
|
142
|
+
* Navigate.reloadPage(),
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
146
|
+
*
|
|
147
|
+
* @see {@link BrowseTheWeb}
|
|
148
|
+
* @see {@link Cookie}
|
|
149
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
150
|
+
* @see {@link @serenity-js/assertions/lib/expectations~endsWith}
|
|
151
|
+
*/
|
|
152
|
+
static reloadPage() {
|
|
153
|
+
return core_1.Interaction.where(`#actor reloads the page`, actor => abilities_1.BrowseTheWeb.as(actor).reloadPage());
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.Navigate = Navigate;
|
|
157
|
+
/**
|
|
158
|
+
* @package
|
|
159
|
+
*/
|
|
160
|
+
class NavigateToUrl extends core_1.Interaction {
|
|
161
|
+
constructor(url) {
|
|
162
|
+
super();
|
|
163
|
+
this.url = url;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @desc
|
|
167
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
168
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
169
|
+
*
|
|
170
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
171
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
172
|
+
* to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
173
|
+
*
|
|
174
|
+
* @returns {PromiseLike<void>}
|
|
175
|
+
*
|
|
176
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
177
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
178
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
179
|
+
*/
|
|
180
|
+
performAs(actor) {
|
|
181
|
+
return actor.answer(this.url)
|
|
182
|
+
.then(url => abilities_1.BrowseTheWeb.as(actor)
|
|
183
|
+
.navigateTo(url)
|
|
184
|
+
.catch(error => {
|
|
185
|
+
throw new core_1.TestCompromisedError(`Couldn't navigate to ${url}`, error);
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @desc
|
|
190
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
191
|
+
*
|
|
192
|
+
* @returns {string}
|
|
193
|
+
*/
|
|
194
|
+
toString() {
|
|
195
|
+
return (0, io_1.formatted) `#actor navigates to ${this.url}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=Navigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Navigate.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Navigate.ts"],"names":[],"mappings":";;;AAAA,4CAAmH;AACnH,iDAAqD;AAErD,4CAA4C;AAE5C;;;;;GAKG;AACH,MAAa,QAAQ;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,MAAM,CAAC,EAAE,CAAC,GAAuB;QAC7B,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,kBAAW,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,EAAE,CAC7E,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CACxC,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,OAAO;QACV,OAAO,kBAAW,CAAC,KAAK,CAAC,iDAAiD,EAAE,KAAK,CAAC,EAAE,CAChF,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,CAC3C,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,UAAU;QACb,OAAO,kBAAW,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,EAAE,CACxD,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CACtC,CAAC;IACN,CAAC;CACJ;AAxJD,4BAwJC;AAED;;GAEG;AACH,MAAM,aAAc,SAAQ,kBAAW;IACnC,YAA6B,GAAuB;QAChD,KAAK,EAAE,CAAC;QADiB,QAAG,GAAH,GAAG,CAAoB;IAEpD,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,KAAuC;QAC7C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;aACxB,IAAI,CAAC,GAAG,CAAC,EAAE,CACR,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC;aACjB,UAAU,CAAC,GAAG,CAAC;aACf,KAAK,CAAC,KAAK,CAAC,EAAE;YACX,MAAM,IAAI,2BAAoB,CAAC,wBAAyB,GAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3E,CAAC,CAAC,CACT,CAAA;IACT,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAA,cAAS,EAAC,uBAAwB,IAAI,CAAC,GAAI,EAAE,CAAC;IACzD,CAAC;CACJ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Answerable, AnswersQuestions, Interaction } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* A base class for interactions with {@link PageElement}s.
|
|
6
|
+
*
|
|
7
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class PageElementInteraction extends Interaction {
|
|
10
|
+
private readonly description;
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} description
|
|
13
|
+
* A human-readable description to be used when reporting
|
|
14
|
+
* this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
15
|
+
*
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected constructor(description: string);
|
|
19
|
+
/**
|
|
20
|
+
* @desc
|
|
21
|
+
* Returns the resolved {@link PageElement}, or throws a {@link @serenity-js/core/lib/errors~LogicError}
|
|
22
|
+
* if the element is `undefined`.
|
|
23
|
+
*
|
|
24
|
+
* @param {@serenity-js/core/lib/screenplay/actor~AnswersQuestions} actor
|
|
25
|
+
* @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} element
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<PageElement>}
|
|
28
|
+
*
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
protected resolve(actor: AnswersQuestions, element: Answerable<PageElement>): Promise<PageElement>;
|
|
32
|
+
/**
|
|
33
|
+
* @desc
|
|
34
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
35
|
+
*
|
|
36
|
+
* @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
toString(): string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageElementInteraction = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const io_1 = require("@serenity-js/core/lib/io");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* A base class for interactions with {@link PageElement}s.
|
|
9
|
+
*
|
|
10
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
11
|
+
*/
|
|
12
|
+
class PageElementInteraction extends core_1.Interaction {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} description
|
|
15
|
+
* A human-readable description to be used when reporting
|
|
16
|
+
* this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
17
|
+
*
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
20
|
+
constructor(description) {
|
|
21
|
+
super();
|
|
22
|
+
this.description = description;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @desc
|
|
26
|
+
* Returns the resolved {@link PageElement}, or throws a {@link @serenity-js/core/lib/errors~LogicError}
|
|
27
|
+
* if the element is `undefined`.
|
|
28
|
+
*
|
|
29
|
+
* @param {@serenity-js/core/lib/screenplay/actor~AnswersQuestions} actor
|
|
30
|
+
* @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} element
|
|
31
|
+
*
|
|
32
|
+
* @returns {Promise<PageElement>}
|
|
33
|
+
*
|
|
34
|
+
* @protected
|
|
35
|
+
*/
|
|
36
|
+
async resolve(actor, element) {
|
|
37
|
+
const resolved = await actor.answer(element);
|
|
38
|
+
if (!resolved) {
|
|
39
|
+
throw new core_1.LogicError((0, io_1.formatted) `Couldn't find ${element}`);
|
|
40
|
+
}
|
|
41
|
+
return resolved;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @desc
|
|
45
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
46
|
+
*
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
toString() {
|
|
50
|
+
return this.description;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PageElementInteraction = PageElementInteraction;
|
|
54
|
+
//# sourceMappingURL=PageElementInteraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageElementInteraction.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/PageElementInteraction.ts"],"names":[],"mappings":";;;AAAA,4CAA0F;AAC1F,iDAAqD;AAIrD;;;;;GAKG;AACH,MAAsB,sBAAuB,SAAQ,kBAAW;IAE5D;;;;;;OAMG;IACH,YAAuC,WAAmB;QACtD,KAAK,EAAE,CAAC;QAD2B,gBAAW,GAAX,WAAW,CAAQ;IAE1D,CAAC;IAED;;;;;;;;;;;OAWG;IACO,KAAK,CAAC,OAAO,CACnB,KAAuB,EACvB,OAAgC;QAEhC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE7C,IAAI,CAAE,QAAQ,EAAE;YACZ,MAAM,IAAI,iBAAU,CAAC,IAAA,cAAS,EAAC,iBAAkB,OAAQ,EAAE,CAAC,CAAC;SAChE;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;CACJ;AA/CD,wDA+CC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Activity, Answerable, AnswersQuestions, Interaction, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { Key } from '../../input';
|
|
3
|
+
import { PageElement } from '../models';
|
|
4
|
+
import { PageElementInteraction } from './PageElementInteraction';
|
|
5
|
+
import { PressBuilder } from './PressBuilder';
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
9
|
+
* send a key press or a sequence of keys to a Web element.
|
|
10
|
+
*
|
|
11
|
+
* *Please note*: On macOS, some keyboard shortcuts might not work with the [`devtools` protocol](https://webdriver.io/docs/automationProtocols/#devtools-protocol).
|
|
12
|
+
*
|
|
13
|
+
* For example:
|
|
14
|
+
* - to *copy*, instead of `Meta+C`, use `Control+Insert`
|
|
15
|
+
* - to *cut*, instead of `Meta+X`, use `Control+Delete`
|
|
16
|
+
* - to *paste*, instead of `Meta+V`, use `Shift+Insert`
|
|
17
|
+
*
|
|
18
|
+
* @example <caption>Example widget</caption>
|
|
19
|
+
* <form>
|
|
20
|
+
* <input type="text" name="example" id="example" />
|
|
21
|
+
* </form>
|
|
22
|
+
*
|
|
23
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
24
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
25
|
+
*
|
|
26
|
+
* class Form {
|
|
27
|
+
* static exampleInput = Target.the('example input')
|
|
28
|
+
* .located(by.id('example'));
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @example <caption>Pressing keys</caption>
|
|
32
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
33
|
+
* import { BrowseTheWeb, Key, Press, Value } from '@serenity-js/webdriverio';
|
|
34
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
35
|
+
*
|
|
36
|
+
* actorCalled('Priyanka')
|
|
37
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
38
|
+
* .attemptsTo(
|
|
39
|
+
* Press.the('H', 'i', '!', Key.ENTER).in(Form.exampleInput),
|
|
40
|
+
* Ensure.that(Value.of(Form.exampleInput), equals('Hi!')),
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* @see {@link Key}
|
|
44
|
+
* @see {@link BrowseTheWeb}
|
|
45
|
+
* @see {@link Target}
|
|
46
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
47
|
+
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
48
|
+
*
|
|
49
|
+
* @extends {ElementInteraction}
|
|
50
|
+
*/
|
|
51
|
+
export declare class Press extends PageElementInteraction {
|
|
52
|
+
private readonly keys;
|
|
53
|
+
/**
|
|
54
|
+
* @desc
|
|
55
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
56
|
+
*
|
|
57
|
+
* @param {...keys: Array<Answerable<Key | string | Key[] | string[]>>} keys
|
|
58
|
+
* A sequence of one or more keys to press
|
|
59
|
+
*
|
|
60
|
+
* @returns {PressBuilder}
|
|
61
|
+
*/
|
|
62
|
+
static the(...keys: Array<Answerable<Key | string | Key[] | string[]>>): Activity & PressBuilder;
|
|
63
|
+
in(field: Answerable<PageElement>): Interaction;
|
|
64
|
+
/**
|
|
65
|
+
* @param {Answerable<Array<Key | string>>} keys
|
|
66
|
+
* A sequence of one or more keys to press
|
|
67
|
+
*/
|
|
68
|
+
constructor(keys: Answerable<Array<Key | string>>);
|
|
69
|
+
/**
|
|
70
|
+
* @desc
|
|
71
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
72
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
73
|
+
*
|
|
74
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
75
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
76
|
+
*
|
|
77
|
+
* @returns {PromiseLike<void>}
|
|
78
|
+
*
|
|
79
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
80
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
81
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
82
|
+
*/
|
|
83
|
+
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
84
|
+
}
|