@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,150 @@
|
|
|
1
|
+
import { Activity, Answerable, AnswersQuestions, Interaction, Task, UsesAbilities } from '@serenity-js/core';
|
|
2
|
+
import { PageElement } from '../models';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
6
|
+
* to switch to a different [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame),
|
|
7
|
+
* [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe),
|
|
8
|
+
* or browser window/tab.
|
|
9
|
+
*
|
|
10
|
+
* @example <caption>Lean Page Object describing a login form, embedded in an iframe</caption>
|
|
11
|
+
*
|
|
12
|
+
* import { Target } from '@serenity-js/protractor';
|
|
13
|
+
* import { by } from 'protractor';
|
|
14
|
+
*
|
|
15
|
+
* class LoginForm {
|
|
16
|
+
* static iframe = Target.the('login form').located(by.tagName('iframe'));
|
|
17
|
+
* static usernameField = Target.the('username field').located(by.css('[data-test="username"]'));
|
|
18
|
+
* static passwordField = Target.the('password field').located(by.css('[data-test="password"]'));
|
|
19
|
+
* static submitButton = Target.the('submit button').located(by.css(`button[type='submit']`));
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* @example <caption>Switch to an iframe and back</caption>
|
|
23
|
+
*
|
|
24
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
25
|
+
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
26
|
+
* import { protractor } from 'protractor';
|
|
27
|
+
*
|
|
28
|
+
* actorCalled('Francesca')
|
|
29
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
30
|
+
* .attemptsTo(
|
|
31
|
+
* Switch.toFrame(LoginForm.iframe),
|
|
32
|
+
*
|
|
33
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
34
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
35
|
+
* Click.on(LoginForm.submitButton),
|
|
36
|
+
*
|
|
37
|
+
* Switch.toParentFrame(),
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* @example <caption>Perform activities in the context of an iframe</caption>
|
|
41
|
+
*
|
|
42
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
43
|
+
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
44
|
+
* import { protractor } from 'protractor';
|
|
45
|
+
*
|
|
46
|
+
* actorCalled('Francesca')
|
|
47
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
48
|
+
* .attemptsTo(
|
|
49
|
+
* Switch.toFrame(LoginForm.iframe).and(
|
|
50
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
51
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
52
|
+
* Click.on(LoginForm.submitButton),
|
|
53
|
+
* ),
|
|
54
|
+
* // Note that Switch.toParentFrame() is invoked automatically
|
|
55
|
+
* );
|
|
56
|
+
*
|
|
57
|
+
* @example <caption>Switch to a new window/tab and back</caption>
|
|
58
|
+
*
|
|
59
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
60
|
+
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
61
|
+
* import { protractor } from 'protractor';
|
|
62
|
+
*
|
|
63
|
+
* actorCalled('Francesca')
|
|
64
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
65
|
+
* .attemptsTo(
|
|
66
|
+
* Switch.toNewWindow(), // or: Switch.toWindow(...)
|
|
67
|
+
*
|
|
68
|
+
* // perform some activities in the context of the new window
|
|
69
|
+
*
|
|
70
|
+
* Close.currentWindow(),
|
|
71
|
+
*
|
|
72
|
+
* Switch.toOriginalWindow(),
|
|
73
|
+
* );
|
|
74
|
+
*
|
|
75
|
+
* @example <caption>Perform activities in the context of a different window/tab</caption>
|
|
76
|
+
*
|
|
77
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
78
|
+
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
79
|
+
* import { protractor } from 'protractor';
|
|
80
|
+
*
|
|
81
|
+
* actorCalled('Francesca')
|
|
82
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
83
|
+
* .attemptsTo(
|
|
84
|
+
* Switch.toNewWindow().and(
|
|
85
|
+
* // perform some activities in the context of the new window
|
|
86
|
+
*
|
|
87
|
+
* Close.currentWindow()
|
|
88
|
+
* ),
|
|
89
|
+
*
|
|
90
|
+
* // Note that Switch.toOriginalWindow() is invoked automatically
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* @see {@link Close}
|
|
94
|
+
* @see {@link BrowseTheWeb}
|
|
95
|
+
*/
|
|
96
|
+
export declare class Switch {
|
|
97
|
+
/**
|
|
98
|
+
* @desc
|
|
99
|
+
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
100
|
+
* for future commands to a [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame)
|
|
101
|
+
* or an [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
|
|
102
|
+
* identified by its name, index or `Question<ElementFinder>`.
|
|
103
|
+
*
|
|
104
|
+
* @param {Answerable<ElementFinder | number | string>} targetOrIndex
|
|
105
|
+
*
|
|
106
|
+
* @returns {SwitchToFrame}
|
|
107
|
+
*
|
|
108
|
+
* @see {@link Switch.toParentFrame}
|
|
109
|
+
* @see {@link Switch.toDefaultContent}
|
|
110
|
+
* @see {@link Target}
|
|
111
|
+
*/
|
|
112
|
+
static toFrame(targetOrIndex: Answerable<PageElement | number | string>): SwitchToFrame;
|
|
113
|
+
/**
|
|
114
|
+
* @desc
|
|
115
|
+
* Sets the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
116
|
+
* for future commands to the parent of the current browsing context,
|
|
117
|
+
* i.e. an `iframe` in which the current `iframe` is nested.
|
|
118
|
+
*
|
|
119
|
+
* If the current context is the top-level browsing context, the context remains unchanged.
|
|
120
|
+
*
|
|
121
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
122
|
+
*
|
|
123
|
+
* @see {@link Switch.toFrame}
|
|
124
|
+
* @see https://w3c.github.io/webdriver/#switch-to-parent-frame
|
|
125
|
+
* @see https://w3c.github.io/webdriver/#dfn-current-browsing-context
|
|
126
|
+
*/
|
|
127
|
+
static toParentFrame(): Interaction;
|
|
128
|
+
/**
|
|
129
|
+
* @desc
|
|
130
|
+
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
131
|
+
* for future commands to the first frame on the page, or the main document
|
|
132
|
+
* when a page contains [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)s.
|
|
133
|
+
*
|
|
134
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
135
|
+
*
|
|
136
|
+
* @see {@link Switch.toFrame}
|
|
137
|
+
*/
|
|
138
|
+
static toDefaultContent(): Interaction;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @package
|
|
142
|
+
*/
|
|
143
|
+
declare class SwitchToFrame extends Interaction {
|
|
144
|
+
private readonly targetOrIndex;
|
|
145
|
+
constructor(targetOrIndex: Answerable<PageElement | number | string>);
|
|
146
|
+
and(...activities: Activity[]): Task;
|
|
147
|
+
performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void>;
|
|
148
|
+
toString(): string;
|
|
149
|
+
}
|
|
150
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Switch = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const abilities_1 = require("../abilities");
|
|
6
|
+
/**
|
|
7
|
+
* @desc
|
|
8
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
9
|
+
* to switch to a different [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame),
|
|
10
|
+
* [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe),
|
|
11
|
+
* or browser window/tab.
|
|
12
|
+
*
|
|
13
|
+
* @example <caption>Lean Page Object describing a login form, embedded in an iframe</caption>
|
|
14
|
+
*
|
|
15
|
+
* import { Target } from '@serenity-js/protractor';
|
|
16
|
+
* import { by } from 'protractor';
|
|
17
|
+
*
|
|
18
|
+
* class LoginForm {
|
|
19
|
+
* static iframe = Target.the('login form').located(by.tagName('iframe'));
|
|
20
|
+
* static usernameField = Target.the('username field').located(by.css('[data-test="username"]'));
|
|
21
|
+
* static passwordField = Target.the('password field').located(by.css('[data-test="password"]'));
|
|
22
|
+
* static submitButton = Target.the('submit button').located(by.css(`button[type='submit']`));
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @example <caption>Switch to an iframe and back</caption>
|
|
26
|
+
*
|
|
27
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
28
|
+
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
29
|
+
* import { protractor } from 'protractor';
|
|
30
|
+
*
|
|
31
|
+
* actorCalled('Francesca')
|
|
32
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
33
|
+
* .attemptsTo(
|
|
34
|
+
* Switch.toFrame(LoginForm.iframe),
|
|
35
|
+
*
|
|
36
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
37
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
38
|
+
* Click.on(LoginForm.submitButton),
|
|
39
|
+
*
|
|
40
|
+
* Switch.toParentFrame(),
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* @example <caption>Perform activities in the context of an iframe</caption>
|
|
44
|
+
*
|
|
45
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
46
|
+
* import { BrowseTheWeb, Switch, Enter, Click } from '@serenity-js/protractor';
|
|
47
|
+
* import { protractor } from 'protractor';
|
|
48
|
+
*
|
|
49
|
+
* actorCalled('Francesca')
|
|
50
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
51
|
+
* .attemptsTo(
|
|
52
|
+
* Switch.toFrame(LoginForm.iframe).and(
|
|
53
|
+
* Enter.theValue('francesca@example.org').into(LoginForm.usernameField),
|
|
54
|
+
* Enter.theValue('correct-horse-battery-staple').into(LoginForm.passwordField),
|
|
55
|
+
* Click.on(LoginForm.submitButton),
|
|
56
|
+
* ),
|
|
57
|
+
* // Note that Switch.toParentFrame() is invoked automatically
|
|
58
|
+
* );
|
|
59
|
+
*
|
|
60
|
+
* @example <caption>Switch to a new window/tab and back</caption>
|
|
61
|
+
*
|
|
62
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
63
|
+
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
64
|
+
* import { protractor } from 'protractor';
|
|
65
|
+
*
|
|
66
|
+
* actorCalled('Francesca')
|
|
67
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
68
|
+
* .attemptsTo(
|
|
69
|
+
* Switch.toNewWindow(), // or: Switch.toWindow(...)
|
|
70
|
+
*
|
|
71
|
+
* // perform some activities in the context of the new window
|
|
72
|
+
*
|
|
73
|
+
* Close.currentWindow(),
|
|
74
|
+
*
|
|
75
|
+
* Switch.toOriginalWindow(),
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* @example <caption>Perform activities in the context of a different window/tab</caption>
|
|
79
|
+
*
|
|
80
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
81
|
+
* import { BrowseTheWeb, Switch, Close } from '@serenity-js/protractor';
|
|
82
|
+
* import { protractor } from 'protractor';
|
|
83
|
+
*
|
|
84
|
+
* actorCalled('Francesca')
|
|
85
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
86
|
+
* .attemptsTo(
|
|
87
|
+
* Switch.toNewWindow().and(
|
|
88
|
+
* // perform some activities in the context of the new window
|
|
89
|
+
*
|
|
90
|
+
* Close.currentWindow()
|
|
91
|
+
* ),
|
|
92
|
+
*
|
|
93
|
+
* // Note that Switch.toOriginalWindow() is invoked automatically
|
|
94
|
+
* );
|
|
95
|
+
*
|
|
96
|
+
* @see {@link Close}
|
|
97
|
+
* @see {@link BrowseTheWeb}
|
|
98
|
+
*/
|
|
99
|
+
class Switch {
|
|
100
|
+
/**
|
|
101
|
+
* @desc
|
|
102
|
+
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
103
|
+
* for future commands to a [frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frame)
|
|
104
|
+
* or an [inline frame](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)
|
|
105
|
+
* identified by its name, index or `Question<ElementFinder>`.
|
|
106
|
+
*
|
|
107
|
+
* @param {Answerable<ElementFinder | number | string>} targetOrIndex
|
|
108
|
+
*
|
|
109
|
+
* @returns {SwitchToFrame}
|
|
110
|
+
*
|
|
111
|
+
* @see {@link Switch.toParentFrame}
|
|
112
|
+
* @see {@link Switch.toDefaultContent}
|
|
113
|
+
* @see {@link Target}
|
|
114
|
+
*/
|
|
115
|
+
static toFrame(targetOrIndex) {
|
|
116
|
+
return new SwitchToFrame(targetOrIndex);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @desc
|
|
120
|
+
* Sets the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
121
|
+
* for future commands to the parent of the current browsing context,
|
|
122
|
+
* i.e. an `iframe` in which the current `iframe` is nested.
|
|
123
|
+
*
|
|
124
|
+
* If the current context is the top-level browsing context, the context remains unchanged.
|
|
125
|
+
*
|
|
126
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
127
|
+
*
|
|
128
|
+
* @see {@link Switch.toFrame}
|
|
129
|
+
* @see https://w3c.github.io/webdriver/#switch-to-parent-frame
|
|
130
|
+
* @see https://w3c.github.io/webdriver/#dfn-current-browsing-context
|
|
131
|
+
*/
|
|
132
|
+
static toParentFrame() {
|
|
133
|
+
return new SwitchToParentFrame();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @desc
|
|
137
|
+
* Switches the current [browsing context](https://w3c.github.io/webdriver/#dfn-current-browsing-context)
|
|
138
|
+
* for future commands to the first frame on the page, or the main document
|
|
139
|
+
* when a page contains [`iframe`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe)s.
|
|
140
|
+
*
|
|
141
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
142
|
+
*
|
|
143
|
+
* @see {@link Switch.toFrame}
|
|
144
|
+
*/
|
|
145
|
+
static toDefaultContent() {
|
|
146
|
+
return new SwitchToDefaultContent();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.Switch = Switch;
|
|
150
|
+
/**
|
|
151
|
+
* @package
|
|
152
|
+
*/
|
|
153
|
+
class SwitchToFrame extends core_1.Interaction {
|
|
154
|
+
constructor(targetOrIndex) {
|
|
155
|
+
super();
|
|
156
|
+
this.targetOrIndex = targetOrIndex;
|
|
157
|
+
}
|
|
158
|
+
and(...activities) {
|
|
159
|
+
return new SwitchToFrameAndPerformActivities(this.targetOrIndex, activities);
|
|
160
|
+
}
|
|
161
|
+
performAs(actor) {
|
|
162
|
+
return actor.answer(this.targetOrIndex)
|
|
163
|
+
.then((targetOrIndex) => {
|
|
164
|
+
return abilities_1.BrowseTheWeb.as(actor).switchToFrame(targetOrIndex);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
toString() {
|
|
168
|
+
return `#actor switches to frame: ${this.targetOrIndex}`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @package
|
|
173
|
+
*/
|
|
174
|
+
class SwitchToFrameAndPerformActivities extends core_1.Task {
|
|
175
|
+
constructor(targetOrIndex, activities) {
|
|
176
|
+
super();
|
|
177
|
+
this.targetOrIndex = targetOrIndex;
|
|
178
|
+
this.activities = activities;
|
|
179
|
+
}
|
|
180
|
+
performAs(actor) {
|
|
181
|
+
return actor.attemptsTo(new SwitchToFrame(this.targetOrIndex), ...this.activities, new SwitchToParentFrame());
|
|
182
|
+
}
|
|
183
|
+
toString() {
|
|
184
|
+
return `#actor switches to frame: ${this.targetOrIndex}`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @package
|
|
189
|
+
*/
|
|
190
|
+
class SwitchToParentFrame extends core_1.Interaction {
|
|
191
|
+
performAs(actor) {
|
|
192
|
+
return abilities_1.BrowseTheWeb.as(actor).switchToParentFrame();
|
|
193
|
+
}
|
|
194
|
+
toString() {
|
|
195
|
+
return `#actor switches to parent frame`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* @package
|
|
200
|
+
*/
|
|
201
|
+
class SwitchToDefaultContent extends core_1.Interaction {
|
|
202
|
+
performAs(actor) {
|
|
203
|
+
return abilities_1.BrowseTheWeb.as(actor).switchToDefaultContent();
|
|
204
|
+
}
|
|
205
|
+
toString() {
|
|
206
|
+
return `#actor switches to default content`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Switch.ts"],"names":[],"mappings":";;;AAAA,4CAAiI;AAEjI,4CAA4C;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,MAAa,MAAM;IAEf;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,CAAC,aAAwD;QACnE,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa;QAChB,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,gBAAgB;QACnB,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACxC,CAAC;CACJ;AApDD,wBAoDC;AAED;;GAEG;AACH,MAAM,aAAc,SAAQ,kBAAW;IACnC,YAA6B,aAAwD;QACjF,KAAK,EAAE,CAAC;QADiB,kBAAa,GAAb,aAAa,CAA2C;IAErF,CAAC;IAED,GAAG,CAAC,GAAG,UAAsB;QACzB,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACjF,CAAC;IAED,SAAS,CAAC,KAAuC;QAC7C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;aAClC,IAAI,CAAC,CAAC,aAA4C,EAAE,EAAE;YACnD,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACX,CAAC;IAED,QAAQ;QACJ,OAAO,6BAA8B,IAAI,CAAC,aAAc,EAAE,CAAC;IAC/D,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,iCAAkC,SAAQ,WAAI;IAChD,YACqB,aAAwD,EACxD,UAAsB;QAEvC,KAAK,EAAE,CAAC;QAHS,kBAAa,GAAb,aAAa,CAA2C;QACxD,eAAU,GAAV,UAAU,CAAY;IAG3C,CAAC;IAED,SAAS,CAAC,KAAyB;QAC/B,OAAO,KAAK,CAAC,UAAU,CACnB,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EACrC,GAAG,IAAI,CAAC,UAAU,EAClB,IAAI,mBAAmB,EAAE,CAC5B,CAAA;IACL,CAAC;IAED,QAAQ;QACJ,OAAO,6BAA8B,IAAI,CAAC,aAAc,EAAE,CAAC;IAC/D,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,mBAAoB,SAAQ,kBAAW;IACzC,SAAS,CAAC,KAAuC;QAC7C,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACxD,CAAC;IAED,QAAQ;QACJ,OAAO,iCAAiC,CAAC;IAC7C,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,sBAAuB,SAAQ,kBAAW;IAC5C,SAAS,CAAC,KAAuC;QAC7C,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,sBAAsB,EAAE,CAAC;IAC3D,CAAC;IAED,QAAQ;QACJ,OAAO,oCAAoC,CAAC;IAChD,CAAC;CACJ"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
* take a screenshot and emit an {@link @serenity-js/core/lib/model~Artifact},
|
|
6
|
+
* which can then be persisted by {@link @serenity-js/core/lib/stage/crew/artifact-archiver~ArtifactArchiver}
|
|
7
|
+
* and reported by [Serenity BDD reporter](/modules/serenity-bdd).
|
|
8
|
+
*
|
|
9
|
+
* @example <caption>Clicking on an element</caption>
|
|
10
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
11
|
+
* import { BrowseTheWeb, Navigate, TakeScreenshot } from '@serenity-js/protractor';
|
|
12
|
+
* import { protractor } from 'protractor';
|
|
13
|
+
*
|
|
14
|
+
* actorCalled('Tania')
|
|
15
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
16
|
+
* .attemptsTo(
|
|
17
|
+
* Navigate.to('/app'),
|
|
18
|
+
* TakeScreenshot.of('my app'),
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* @see {@link BrowseTheWeb}
|
|
22
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~CollectsArtifacts}
|
|
23
|
+
* @see {@link @serenity-js/core/lib/model~Artifact}
|
|
24
|
+
* @see {@link @serenity-js/core/lib/stage/crew/artifact-archiver~ArtifactArchiver}
|
|
25
|
+
*
|
|
26
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
27
|
+
*/
|
|
28
|
+
export declare class TakeScreenshot extends Interaction {
|
|
29
|
+
private readonly name;
|
|
30
|
+
/**
|
|
31
|
+
* @desc
|
|
32
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
33
|
+
*
|
|
34
|
+
* @param {Answerable<string>} name
|
|
35
|
+
* The name to associate the screenshot with
|
|
36
|
+
*
|
|
37
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
38
|
+
*/
|
|
39
|
+
static of(name: Answerable<string>): Interaction;
|
|
40
|
+
/**
|
|
41
|
+
* @param {Answerable<string>} name
|
|
42
|
+
* The name to associate the screenshot with
|
|
43
|
+
*/
|
|
44
|
+
constructor(name: Answerable<string>);
|
|
45
|
+
/**
|
|
46
|
+
* @desc
|
|
47
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
48
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
49
|
+
*
|
|
50
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
51
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
52
|
+
*
|
|
53
|
+
* @returns {PromiseLike<void>}
|
|
54
|
+
*
|
|
55
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
56
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
57
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
58
|
+
*/
|
|
59
|
+
performAs(actor: UsesAbilities & AnswersQuestions & CollectsArtifacts): PromiseLike<void>;
|
|
60
|
+
/**
|
|
61
|
+
* @desc
|
|
62
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
63
|
+
*
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
toString(): string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TakeScreenshot = 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
|
+
* take a screenshot and emit an {@link @serenity-js/core/lib/model~Artifact},
|
|
12
|
+
* which can then be persisted by {@link @serenity-js/core/lib/stage/crew/artifact-archiver~ArtifactArchiver}
|
|
13
|
+
* and reported by [Serenity BDD reporter](/modules/serenity-bdd).
|
|
14
|
+
*
|
|
15
|
+
* @example <caption>Clicking on an element</caption>
|
|
16
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
17
|
+
* import { BrowseTheWeb, Navigate, TakeScreenshot } from '@serenity-js/protractor';
|
|
18
|
+
* import { protractor } from 'protractor';
|
|
19
|
+
*
|
|
20
|
+
* actorCalled('Tania')
|
|
21
|
+
* .whoCan(BrowseTheWeb.using(protractor.browser))
|
|
22
|
+
* .attemptsTo(
|
|
23
|
+
* Navigate.to('/app'),
|
|
24
|
+
* TakeScreenshot.of('my app'),
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* @see {@link BrowseTheWeb}
|
|
28
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~CollectsArtifacts}
|
|
29
|
+
* @see {@link @serenity-js/core/lib/model~Artifact}
|
|
30
|
+
* @see {@link @serenity-js/core/lib/stage/crew/artifact-archiver~ArtifactArchiver}
|
|
31
|
+
*
|
|
32
|
+
* @extends {@serenity-js/core/lib/screenplay~Interaction}
|
|
33
|
+
*/
|
|
34
|
+
class TakeScreenshot extends core_1.Interaction {
|
|
35
|
+
/**
|
|
36
|
+
* @param {Answerable<string>} name
|
|
37
|
+
* The name to associate the screenshot with
|
|
38
|
+
*/
|
|
39
|
+
constructor(name) {
|
|
40
|
+
super();
|
|
41
|
+
this.name = name;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @desc
|
|
45
|
+
* Instantiates this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
46
|
+
*
|
|
47
|
+
* @param {Answerable<string>} name
|
|
48
|
+
* The name to associate the screenshot with
|
|
49
|
+
*
|
|
50
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
51
|
+
*/
|
|
52
|
+
static of(name) {
|
|
53
|
+
return new TakeScreenshot(name);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @desc
|
|
57
|
+
* Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
58
|
+
* perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
|
|
59
|
+
*
|
|
60
|
+
* @param {UsesAbilities & AnswersQuestions} actor
|
|
61
|
+
* An {@link @serenity-js/core/lib/screenplay/actor~Actor} to perform this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
62
|
+
*
|
|
63
|
+
* @returns {PromiseLike<void>}
|
|
64
|
+
*
|
|
65
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
66
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
|
|
67
|
+
* @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
|
|
68
|
+
*/
|
|
69
|
+
performAs(actor) {
|
|
70
|
+
return Promise.all([
|
|
71
|
+
abilities_1.BrowseTheWeb.as(actor).takeScreenshot(),
|
|
72
|
+
actor.answer(this.name),
|
|
73
|
+
]).then(([screenshot, name]) => actor.collect(model_1.Photo.fromBase64(screenshot), new model_1.Name(name)));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @desc
|
|
77
|
+
* Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
|
|
78
|
+
*
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
toString() {
|
|
82
|
+
return (0, io_1.formatted) `#actor takes a screenshot of ${this.name}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.TakeScreenshot = TakeScreenshot;
|
|
86
|
+
//# sourceMappingURL=TakeScreenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TakeScreenshot.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/TakeScreenshot.ts"],"names":[],"mappings":";;;AAAA,4CAAgH;AAChH,iDAAqD;AACrD,uDAA0D;AAE1D,4CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,cAAe,SAAQ,kBAAW;IAe3C;;;OAGG;IACH,YAA6B,IAAwB;QACjD,KAAK,EAAE,CAAC;QADiB,SAAI,GAAJ,IAAI,CAAoB;IAErD,CAAC;IAnBD;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,CAAC,IAAwB;QAC9B,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAUD;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,KAA2D;QACjE,OAAO,OAAO,CAAC,GAAG,CAAC;YACf,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE;YACvC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,UAAU,EAAE,IAAI,CAAE,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAC3C,aAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAC5B,IAAI,YAAI,CAAC,IAAI,CAAC,CACjB,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAA,cAAS,EAAC,gCAAgC,IAAI,CAAC,IAAI,EAAE,CAAC;IACjE,CAAC;CACJ;AAxDD,wCAwDC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Answerable, Duration, Expectation, Interaction } from '@serenity-js/core';
|
|
2
|
+
import { WaitBuilder } from './WaitBuilder';
|
|
3
|
+
/**
|
|
4
|
+
* @desc
|
|
5
|
+
* Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
|
|
6
|
+
* wait before proceeding either for a set {@link @serenity-js/core/lib/model~Duration}
|
|
7
|
+
* or until a given {@link @serenity-js/core/lib/screenplay/questions~Expectation} is met.
|
|
8
|
+
*
|
|
9
|
+
* Under the hood, `Wait` uses WebdriverIO ["explicit waiting"](https://webdriver.io/docs/autowait/)
|
|
10
|
+
* mechanism.
|
|
11
|
+
*
|
|
12
|
+
* @example <caption>Example widget</caption>
|
|
13
|
+
* <!--
|
|
14
|
+
* After about 1 second, the text will change from 'Loading...' to 'Ready!'
|
|
15
|
+
* -->
|
|
16
|
+
* <h1 id="status">Loading...</h1>
|
|
17
|
+
* <script>
|
|
18
|
+
* (function () {
|
|
19
|
+
* setTimeout(function () {
|
|
20
|
+
* document.getElementById('status').textContent = 'Ready!'
|
|
21
|
+
* }, 1000);
|
|
22
|
+
* })();
|
|
23
|
+
* </script>
|
|
24
|
+
*
|
|
25
|
+
* @example <caption>Lean Page Object describing the widget</caption>
|
|
26
|
+
* import { by, Target } from '@serenity-js/webdriverio';
|
|
27
|
+
*
|
|
28
|
+
* class App {
|
|
29
|
+
* static status = Target.the('status widget')
|
|
30
|
+
* .located(by.id('status'));
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @example <caption>Waiting for a set amount of time</caption>
|
|
34
|
+
* import { actorCalled, Duration } from '@serenity-js/core';
|
|
35
|
+
* import { BrowseTheWeb, Wait } from '@serenity-js/webdriverio';
|
|
36
|
+
* import { Ensure, equals } from '@serenity-js/assertions';
|
|
37
|
+
*
|
|
38
|
+
* actorCalled('Wendy')
|
|
39
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
40
|
+
* .attemptsTo(
|
|
41
|
+
* Wait.for(Duration.ofSeconds(1.5)),
|
|
42
|
+
* Ensure.that(App.status, equals('Ready!')),
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* // Please note that while the above implementation works,
|
|
46
|
+
* // this approach is inefficient because at best
|
|
47
|
+
* // the actor might wait too long and at worst the test
|
|
48
|
+
* // might become "flaky" if any external interference
|
|
49
|
+
* // (like network glitches, animations taking a bit too long etc.)
|
|
50
|
+
* // makes the actor wait not long enough.
|
|
51
|
+
*
|
|
52
|
+
* @example <caption>Waiting until a condition is met</caption>
|
|
53
|
+
* import { actorCalled } from '@serenity-js/core';
|
|
54
|
+
* import { BrowseTheWeb, Wait, Text } from '@serenity-js/webdriverio';
|
|
55
|
+
* import { equals } from '@serenity-js/assertions';
|
|
56
|
+
*
|
|
57
|
+
* actorCalled('Wendy')
|
|
58
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
59
|
+
* .attemptsTo(
|
|
60
|
+
* Wait.until(Text.of(App.status), equals('Ready!')),
|
|
61
|
+
* // app is ready, proceed with the scenario
|
|
62
|
+
* );
|
|
63
|
+
*
|
|
64
|
+
* // Wait.until makes the Actor keep asking a Question,
|
|
65
|
+
* // in this case Text.of(App.status), until the answer meets
|
|
66
|
+
* // the expectation, or a timeout expires (default: 5s).
|
|
67
|
+
* //
|
|
68
|
+
* // Please note that both Ensure and Wait can be used with
|
|
69
|
+
* // the same expectations, like `equals`.
|
|
70
|
+
*
|
|
71
|
+
* @example <caption>Changing the default timeout</caption>
|
|
72
|
+
* import { actorCalled, Duration } from '@serenity-js/core';
|
|
73
|
+
* import { BrowseTheWeb, Wait, Text } from '@serenity-js/webdriverio';
|
|
74
|
+
* import { equals } from '@serenity-js/assertions';
|
|
75
|
+
*
|
|
76
|
+
* actorCalled('Wendy')
|
|
77
|
+
* .whoCan(BrowseTheWeb.using(browser))
|
|
78
|
+
* .attemptsTo(
|
|
79
|
+
* Wait.upTo(Duration.ofSeconds(3))
|
|
80
|
+
* .until(Text.of(App.status), equals('Ready!')),
|
|
81
|
+
* // app is ready, proceed with the scenario
|
|
82
|
+
* );
|
|
83
|
+
*
|
|
84
|
+
* @see {@link BrowseTheWeb}
|
|
85
|
+
* @see {@link Target}
|
|
86
|
+
* @see {@link Text}
|
|
87
|
+
* @see {@link @serenity-js/assertions~Ensure}
|
|
88
|
+
* @see {@link @serenity-js/assertions/lib/expectations~equals}
|
|
89
|
+
* @see {@link @serenity-js/core/lib/model~Duration}
|
|
90
|
+
*
|
|
91
|
+
* @see {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
92
|
+
*/
|
|
93
|
+
export declare class Wait {
|
|
94
|
+
/**
|
|
95
|
+
* @desc
|
|
96
|
+
* Default timeout of 5 seconds used with {@link Wait.until}.
|
|
97
|
+
*
|
|
98
|
+
* @type {@serenity-js/core~Duration}
|
|
99
|
+
*/
|
|
100
|
+
static readonly Default_Timeout: Duration;
|
|
101
|
+
/**
|
|
102
|
+
* @desc
|
|
103
|
+
* Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
104
|
+
* configured to wait for a set duration.
|
|
105
|
+
*
|
|
106
|
+
* @param {Answerable<Duration>} duration
|
|
107
|
+
* A set duration the {@link @serenity-js/core/lib/screenplay/actor~Actor} should wait for
|
|
108
|
+
* before proceeding
|
|
109
|
+
*
|
|
110
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
111
|
+
*/
|
|
112
|
+
static for(duration: Answerable<Duration>): Interaction;
|
|
113
|
+
/**
|
|
114
|
+
* @desc
|
|
115
|
+
* Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
116
|
+
* configured to wait until the answer to the question (`actual`) meets the `expectation`,
|
|
117
|
+
* or a custom timeout expires.
|
|
118
|
+
*
|
|
119
|
+
* @param {Duration} duration
|
|
120
|
+
* Custom timeout to override {@link Wait.Default_Timeout}
|
|
121
|
+
*
|
|
122
|
+
* @returns {WaitBuilder}
|
|
123
|
+
*/
|
|
124
|
+
static upTo(duration: Duration): WaitBuilder;
|
|
125
|
+
/**
|
|
126
|
+
* @desc
|
|
127
|
+
* Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
|
|
128
|
+
* configured to wait until the answer to the question (`actual`) meets the `expectation`,
|
|
129
|
+
* or a {@link Wait.Default_Timeout} expires.
|
|
130
|
+
*
|
|
131
|
+
* @param {Answerable<Actual>} actual
|
|
132
|
+
* A {@link @serenity-js/core/lib/screenplay~Question}
|
|
133
|
+
* that the {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
134
|
+
* will keep asking until the answer meets
|
|
135
|
+
* the {@link @serenity-js/core/lib/screenplay/questions~Expectation} provided
|
|
136
|
+
*
|
|
137
|
+
* @param {@serenity-js/core/lib/screenplay/questions~<any,Actual>} expectation
|
|
138
|
+
* An {@link @serenity-js/core/lib/screenplay/questions~Expectation} to be met before proceeding
|
|
139
|
+
*
|
|
140
|
+
* @returns {@serenity-js/core/lib/screenplay~Interaction}
|
|
141
|
+
*/
|
|
142
|
+
static until<Actual>(actual: Answerable<Actual>, expectation: Expectation<any, Actual>): Interaction;
|
|
143
|
+
}
|