@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.
Files changed (250) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/LICENSE.md +201 -0
  3. package/NOTICE.md +1 -0
  4. package/README.md +21 -0
  5. package/lib/errors/CookieMissingError.d.ts +4 -0
  6. package/lib/errors/CookieMissingError.js +11 -0
  7. package/lib/errors/CookieMissingError.js.map +1 -0
  8. package/lib/errors/index.d.ts +1 -0
  9. package/lib/errors/index.js +14 -0
  10. package/lib/errors/index.js.map +1 -0
  11. package/lib/expectations/ElementExpectation.d.ts +11 -0
  12. package/lib/expectations/ElementExpectation.js +27 -0
  13. package/lib/expectations/ElementExpectation.js.map +1 -0
  14. package/lib/expectations/index.d.ts +6 -0
  15. package/lib/expectations/index.js +19 -0
  16. package/lib/expectations/index.js.map +1 -0
  17. package/lib/expectations/isActive.d.ts +15 -0
  18. package/lib/expectations/isActive.js +22 -0
  19. package/lib/expectations/isActive.js.map +1 -0
  20. package/lib/expectations/isClickable.d.ts +20 -0
  21. package/lib/expectations/isClickable.js +30 -0
  22. package/lib/expectations/isClickable.js.map +1 -0
  23. package/lib/expectations/isEnabled.d.ts +14 -0
  24. package/lib/expectations/isEnabled.js +20 -0
  25. package/lib/expectations/isEnabled.js.map +1 -0
  26. package/lib/expectations/isPresent.d.ts +15 -0
  27. package/lib/expectations/isPresent.js +22 -0
  28. package/lib/expectations/isPresent.js.map +1 -0
  29. package/lib/expectations/isSelected.d.ts +14 -0
  30. package/lib/expectations/isSelected.js +23 -0
  31. package/lib/expectations/isSelected.js.map +1 -0
  32. package/lib/expectations/isVisible.d.ts +14 -0
  33. package/lib/expectations/isVisible.js +26 -0
  34. package/lib/expectations/isVisible.js.map +1 -0
  35. package/lib/index.d.ts +5 -0
  36. package/lib/index.js +18 -0
  37. package/lib/index.js.map +1 -0
  38. package/lib/input/Key.d.ts +73 -0
  39. package/lib/input/Key.js +84 -0
  40. package/lib/input/Key.js.map +1 -0
  41. package/lib/input/index.d.ts +1 -0
  42. package/lib/input/index.js +14 -0
  43. package/lib/input/index.js.map +1 -0
  44. package/lib/screenplay/abilities/BrowseTheWeb.d.ts +58 -0
  45. package/lib/screenplay/abilities/BrowseTheWeb.js +19 -0
  46. package/lib/screenplay/abilities/BrowseTheWeb.js.map +1 -0
  47. package/lib/screenplay/abilities/BrowserCapabilities.d.ts +5 -0
  48. package/lib/screenplay/abilities/BrowserCapabilities.js +3 -0
  49. package/lib/screenplay/abilities/BrowserCapabilities.js.map +1 -0
  50. package/lib/screenplay/abilities/index.d.ts +2 -0
  51. package/lib/screenplay/abilities/index.js +15 -0
  52. package/lib/screenplay/abilities/index.js.map +1 -0
  53. package/lib/screenplay/index.d.ts +4 -0
  54. package/lib/screenplay/index.js +17 -0
  55. package/lib/screenplay/index.js.map +1 -0
  56. package/lib/screenplay/interactions/Clear.d.ts +79 -0
  57. package/lib/screenplay/interactions/Clear.js +97 -0
  58. package/lib/screenplay/interactions/Clear.js.map +1 -0
  59. package/lib/screenplay/interactions/Click.d.ts +73 -0
  60. package/lib/screenplay/interactions/Click.js +85 -0
  61. package/lib/screenplay/interactions/Click.js.map +1 -0
  62. package/lib/screenplay/interactions/DoubleClick.d.ts +90 -0
  63. package/lib/screenplay/interactions/DoubleClick.js +101 -0
  64. package/lib/screenplay/interactions/DoubleClick.js.map +1 -0
  65. package/lib/screenplay/interactions/Enter.d.ts +73 -0
  66. package/lib/screenplay/interactions/Enter.js +86 -0
  67. package/lib/screenplay/interactions/Enter.js.map +1 -0
  68. package/lib/screenplay/interactions/EnterBuilder.d.ts +25 -0
  69. package/lib/screenplay/interactions/EnterBuilder.js +3 -0
  70. package/lib/screenplay/interactions/EnterBuilder.js.map +1 -0
  71. package/lib/screenplay/interactions/ExecuteScript.d.ts +206 -0
  72. package/lib/screenplay/interactions/ExecuteScript.js +312 -0
  73. package/lib/screenplay/interactions/ExecuteScript.js.map +1 -0
  74. package/lib/screenplay/interactions/Hover.d.ts +78 -0
  75. package/lib/screenplay/interactions/Hover.js +89 -0
  76. package/lib/screenplay/interactions/Hover.js.map +1 -0
  77. package/lib/screenplay/interactions/Navigate.d.ts +142 -0
  78. package/lib/screenplay/interactions/Navigate.js +198 -0
  79. package/lib/screenplay/interactions/Navigate.js.map +1 -0
  80. package/lib/screenplay/interactions/PageElementInteraction.d.ts +39 -0
  81. package/lib/screenplay/interactions/PageElementInteraction.js +54 -0
  82. package/lib/screenplay/interactions/PageElementInteraction.js.map +1 -0
  83. package/lib/screenplay/interactions/Press.d.ts +84 -0
  84. package/lib/screenplay/interactions/Press.js +171 -0
  85. package/lib/screenplay/interactions/Press.js.map +1 -0
  86. package/lib/screenplay/interactions/PressBuilder.d.ts +26 -0
  87. package/lib/screenplay/interactions/PressBuilder.js +3 -0
  88. package/lib/screenplay/interactions/PressBuilder.js.map +1 -0
  89. package/lib/screenplay/interactions/RightClick.d.ts +89 -0
  90. package/lib/screenplay/interactions/RightClick.js +100 -0
  91. package/lib/screenplay/interactions/RightClick.js.map +1 -0
  92. package/lib/screenplay/interactions/Scroll.d.ts +83 -0
  93. package/lib/screenplay/interactions/Scroll.js +97 -0
  94. package/lib/screenplay/interactions/Scroll.js.map +1 -0
  95. package/lib/screenplay/interactions/Select.d.ts +212 -0
  96. package/lib/screenplay/interactions/Select.js +291 -0
  97. package/lib/screenplay/interactions/Select.js.map +1 -0
  98. package/lib/screenplay/interactions/SelectBuilder.d.ts +33 -0
  99. package/lib/screenplay/interactions/SelectBuilder.js +3 -0
  100. package/lib/screenplay/interactions/SelectBuilder.js.map +1 -0
  101. package/lib/screenplay/interactions/Switch.d.ts +150 -0
  102. package/lib/screenplay/interactions/Switch.js +209 -0
  103. package/lib/screenplay/interactions/Switch.js.map +1 -0
  104. package/lib/screenplay/interactions/TakeScreenshot.d.ts +67 -0
  105. package/lib/screenplay/interactions/TakeScreenshot.js +86 -0
  106. package/lib/screenplay/interactions/TakeScreenshot.js.map +1 -0
  107. package/lib/screenplay/interactions/Wait.d.ts +143 -0
  108. package/lib/screenplay/interactions/Wait.js +242 -0
  109. package/lib/screenplay/interactions/Wait.js.map +1 -0
  110. package/lib/screenplay/interactions/WaitBuilder.d.ts +32 -0
  111. package/lib/screenplay/interactions/WaitBuilder.js +3 -0
  112. package/lib/screenplay/interactions/WaitBuilder.js.map +1 -0
  113. package/lib/screenplay/interactions/index.d.ts +16 -0
  114. package/lib/screenplay/interactions/index.js +29 -0
  115. package/lib/screenplay/interactions/index.js.map +1 -0
  116. package/lib/screenplay/models/Cookie.d.ts +117 -0
  117. package/lib/screenplay/models/Cookie.js +176 -0
  118. package/lib/screenplay/models/Cookie.js.map +1 -0
  119. package/lib/screenplay/models/CookieData.d.ts +89 -0
  120. package/lib/screenplay/models/CookieData.js +3 -0
  121. package/lib/screenplay/models/CookieData.js.map +1 -0
  122. package/lib/screenplay/models/ModalDialog.d.ts +9 -0
  123. package/lib/screenplay/models/ModalDialog.js +14 -0
  124. package/lib/screenplay/models/ModalDialog.js.map +1 -0
  125. package/lib/screenplay/models/Page.d.ts +83 -0
  126. package/lib/screenplay/models/Page.js +52 -0
  127. package/lib/screenplay/models/Page.js.map +1 -0
  128. package/lib/screenplay/models/PageElement.d.ts +30 -0
  129. package/lib/screenplay/models/PageElement.js +62 -0
  130. package/lib/screenplay/models/PageElement.js.map +1 -0
  131. package/lib/screenplay/models/PageElements.d.ts +20 -0
  132. package/lib/screenplay/models/PageElements.js +49 -0
  133. package/lib/screenplay/models/PageElements.js.map +1 -0
  134. package/lib/screenplay/models/index.d.ts +6 -0
  135. package/lib/screenplay/models/index.js +19 -0
  136. package/lib/screenplay/models/index.js.map +1 -0
  137. package/lib/screenplay/questions/Attribute.d.ts +83 -0
  138. package/lib/screenplay/questions/Attribute.js +103 -0
  139. package/lib/screenplay/questions/Attribute.js.map +1 -0
  140. package/lib/screenplay/questions/CssClasses.d.ts +93 -0
  141. package/lib/screenplay/questions/CssClasses.js +113 -0
  142. package/lib/screenplay/questions/CssClasses.js.map +1 -0
  143. package/lib/screenplay/questions/ElementQuestion.d.ts +34 -0
  144. package/lib/screenplay/questions/ElementQuestion.js +53 -0
  145. package/lib/screenplay/questions/ElementQuestion.js.map +1 -0
  146. package/lib/screenplay/questions/LastScriptExecution.d.ts +14 -0
  147. package/lib/screenplay/questions/LastScriptExecution.js +22 -0
  148. package/lib/screenplay/questions/LastScriptExecution.js.map +1 -0
  149. package/lib/screenplay/questions/Selected.d.ts +185 -0
  150. package/lib/screenplay/questions/Selected.js +210 -0
  151. package/lib/screenplay/questions/Selected.js.map +1 -0
  152. package/lib/screenplay/questions/Text.d.ts +99 -0
  153. package/lib/screenplay/questions/Text.js +131 -0
  154. package/lib/screenplay/questions/Text.js.map +1 -0
  155. package/lib/screenplay/questions/Value.d.ts +64 -0
  156. package/lib/screenplay/questions/Value.js +78 -0
  157. package/lib/screenplay/questions/Value.js.map +1 -0
  158. package/lib/screenplay/questions/index.d.ts +6 -0
  159. package/lib/screenplay/questions/index.js +19 -0
  160. package/lib/screenplay/questions/index.js.map +1 -0
  161. package/lib/stage/crew/index.d.ts +1 -0
  162. package/lib/stage/crew/index.js +14 -0
  163. package/lib/stage/crew/index.js.map +1 -0
  164. package/lib/stage/crew/photographer/Photographer.d.ts +83 -0
  165. package/lib/stage/crew/photographer/Photographer.js +102 -0
  166. package/lib/stage/crew/photographer/Photographer.js.map +1 -0
  167. package/lib/stage/crew/photographer/index.d.ts +2 -0
  168. package/lib/stage/crew/photographer/index.js +15 -0
  169. package/lib/stage/crew/photographer/index.js.map +1 -0
  170. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +28 -0
  171. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +81 -0
  172. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +1 -0
  173. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +18 -0
  174. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +30 -0
  175. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +1 -0
  176. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +17 -0
  177. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +28 -0
  178. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +1 -0
  179. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +19 -0
  180. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +28 -0
  181. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +1 -0
  182. package/lib/stage/crew/photographer/strategies/index.d.ts +4 -0
  183. package/lib/stage/crew/photographer/strategies/index.js +17 -0
  184. package/lib/stage/crew/photographer/strategies/index.js.map +1 -0
  185. package/lib/stage/index.d.ts +1 -0
  186. package/lib/stage/index.js +14 -0
  187. package/lib/stage/index.js.map +1 -0
  188. package/package.json +85 -0
  189. package/src/errors/CookieMissingError.ts +7 -0
  190. package/src/errors/index.ts +1 -0
  191. package/src/expectations/ElementExpectation.ts +32 -0
  192. package/src/expectations/index.ts +6 -0
  193. package/src/expectations/isActive.ts +22 -0
  194. package/src/expectations/isClickable.ts +32 -0
  195. package/src/expectations/isEnabled.ts +19 -0
  196. package/src/expectations/isPresent.ts +21 -0
  197. package/src/expectations/isSelected.ts +24 -0
  198. package/src/expectations/isVisible.ts +28 -0
  199. package/src/index.ts +5 -0
  200. package/src/input/Key.ts +83 -0
  201. package/src/input/index.ts +1 -0
  202. package/src/screenplay/abilities/BrowseTheWeb.ts +89 -0
  203. package/src/screenplay/abilities/BrowserCapabilities.ts +5 -0
  204. package/src/screenplay/abilities/index.ts +2 -0
  205. package/src/screenplay/index.ts +4 -0
  206. package/src/screenplay/interactions/Clear.ts +102 -0
  207. package/src/screenplay/interactions/Click.ts +86 -0
  208. package/src/screenplay/interactions/DoubleClick.ts +102 -0
  209. package/src/screenplay/interactions/Enter.ts +92 -0
  210. package/src/screenplay/interactions/EnterBuilder.ts +28 -0
  211. package/src/screenplay/interactions/ExecuteScript.ts +345 -0
  212. package/src/screenplay/interactions/Hover.ts +90 -0
  213. package/src/screenplay/interactions/Navigate.ts +209 -0
  214. package/src/screenplay/interactions/PageElementInteraction.ts +59 -0
  215. package/src/screenplay/interactions/Press.ts +194 -0
  216. package/src/screenplay/interactions/PressBuilder.ts +29 -0
  217. package/src/screenplay/interactions/RightClick.ts +100 -0
  218. package/src/screenplay/interactions/Scroll.ts +99 -0
  219. package/src/screenplay/interactions/Select.ts +317 -0
  220. package/src/screenplay/interactions/SelectBuilder.ts +36 -0
  221. package/src/screenplay/interactions/Switch.ts +225 -0
  222. package/src/screenplay/interactions/TakeScreenshot.ts +89 -0
  223. package/src/screenplay/interactions/Wait.ts +264 -0
  224. package/src/screenplay/interactions/WaitBuilder.ts +34 -0
  225. package/src/screenplay/interactions/index.ts +16 -0
  226. package/src/screenplay/models/Cookie.ts +219 -0
  227. package/src/screenplay/models/CookieData.ts +97 -0
  228. package/src/screenplay/models/ModalDialog.ts +19 -0
  229. package/src/screenplay/models/Page.ts +147 -0
  230. package/src/screenplay/models/PageElement.ts +95 -0
  231. package/src/screenplay/models/PageElements.ts +70 -0
  232. package/src/screenplay/models/index.ts +6 -0
  233. package/src/screenplay/questions/Attribute.ts +112 -0
  234. package/src/screenplay/questions/CssClasses.ts +118 -0
  235. package/src/screenplay/questions/ElementQuestion.ts +60 -0
  236. package/src/screenplay/questions/LastScriptExecution.ts +21 -0
  237. package/src/screenplay/questions/Selected.ts +212 -0
  238. package/src/screenplay/questions/Text.ts +153 -0
  239. package/src/screenplay/questions/Value.ts +82 -0
  240. package/src/screenplay/questions/index.ts +6 -0
  241. package/src/stage/crew/index.ts +1 -0
  242. package/src/stage/crew/photographer/Photographer.ts +108 -0
  243. package/src/stage/crew/photographer/index.ts +2 -0
  244. package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +116 -0
  245. package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +28 -0
  246. package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +26 -0
  247. package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +26 -0
  248. package/src/stage/crew/photographer/strategies/index.ts +4 -0
  249. package/src/stage/index.ts +1 -0
  250. package/tsconfig.eslint.json +10 -0
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Wait = 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
+ * Instructs the {@link @serenity-js/core/lib/screenplay/actor~Actor} to
10
+ * wait before proceeding either for a set {@link @serenity-js/core/lib/model~Duration}
11
+ * or until a given {@link @serenity-js/core/lib/screenplay/questions~Expectation} is met.
12
+ *
13
+ * Under the hood, `Wait` uses WebdriverIO ["explicit waiting"](https://webdriver.io/docs/autowait/)
14
+ * mechanism.
15
+ *
16
+ * @example <caption>Example widget</caption>
17
+ * <!--
18
+ * After about 1 second, the text will change from 'Loading...' to 'Ready!'
19
+ * -->
20
+ * <h1 id="status">Loading...</h1>
21
+ * <script>
22
+ * (function () {
23
+ * setTimeout(function () {
24
+ * document.getElementById('status').textContent = 'Ready!'
25
+ * }, 1000);
26
+ * })();
27
+ * </script>
28
+ *
29
+ * @example <caption>Lean Page Object describing the widget</caption>
30
+ * import { by, Target } from '@serenity-js/webdriverio';
31
+ *
32
+ * class App {
33
+ * static status = Target.the('status widget')
34
+ * .located(by.id('status'));
35
+ * }
36
+ *
37
+ * @example <caption>Waiting for a set amount of time</caption>
38
+ * import { actorCalled, Duration } from '@serenity-js/core';
39
+ * import { BrowseTheWeb, Wait } from '@serenity-js/webdriverio';
40
+ * import { Ensure, equals } from '@serenity-js/assertions';
41
+ *
42
+ * actorCalled('Wendy')
43
+ * .whoCan(BrowseTheWeb.using(browser))
44
+ * .attemptsTo(
45
+ * Wait.for(Duration.ofSeconds(1.5)),
46
+ * Ensure.that(App.status, equals('Ready!')),
47
+ * );
48
+ *
49
+ * // Please note that while the above implementation works,
50
+ * // this approach is inefficient because at best
51
+ * // the actor might wait too long and at worst the test
52
+ * // might become "flaky" if any external interference
53
+ * // (like network glitches, animations taking a bit too long etc.)
54
+ * // makes the actor wait not long enough.
55
+ *
56
+ * @example <caption>Waiting until a condition is met</caption>
57
+ * import { actorCalled } from '@serenity-js/core';
58
+ * import { BrowseTheWeb, Wait, Text } from '@serenity-js/webdriverio';
59
+ * import { equals } from '@serenity-js/assertions';
60
+ *
61
+ * actorCalled('Wendy')
62
+ * .whoCan(BrowseTheWeb.using(browser))
63
+ * .attemptsTo(
64
+ * Wait.until(Text.of(App.status), equals('Ready!')),
65
+ * // app is ready, proceed with the scenario
66
+ * );
67
+ *
68
+ * // Wait.until makes the Actor keep asking a Question,
69
+ * // in this case Text.of(App.status), until the answer meets
70
+ * // the expectation, or a timeout expires (default: 5s).
71
+ * //
72
+ * // Please note that both Ensure and Wait can be used with
73
+ * // the same expectations, like `equals`.
74
+ *
75
+ * @example <caption>Changing the default timeout</caption>
76
+ * import { actorCalled, Duration } from '@serenity-js/core';
77
+ * import { BrowseTheWeb, Wait, Text } from '@serenity-js/webdriverio';
78
+ * import { equals } from '@serenity-js/assertions';
79
+ *
80
+ * actorCalled('Wendy')
81
+ * .whoCan(BrowseTheWeb.using(browser))
82
+ * .attemptsTo(
83
+ * Wait.upTo(Duration.ofSeconds(3))
84
+ * .until(Text.of(App.status), equals('Ready!')),
85
+ * // app is ready, proceed with the scenario
86
+ * );
87
+ *
88
+ * @see {@link BrowseTheWeb}
89
+ * @see {@link Target}
90
+ * @see {@link Text}
91
+ * @see {@link @serenity-js/assertions~Ensure}
92
+ * @see {@link @serenity-js/assertions/lib/expectations~equals}
93
+ * @see {@link @serenity-js/core/lib/model~Duration}
94
+ *
95
+ * @see {@link @serenity-js/core/lib/screenplay~Interaction}
96
+ */
97
+ class Wait {
98
+ /**
99
+ * @desc
100
+ * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
101
+ * configured to wait for a set duration.
102
+ *
103
+ * @param {Answerable<Duration>} duration
104
+ * A set duration the {@link @serenity-js/core/lib/screenplay/actor~Actor} should wait for
105
+ * before proceeding
106
+ *
107
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
108
+ */
109
+ static for(duration) {
110
+ return new WaitFor(duration);
111
+ }
112
+ /**
113
+ * @desc
114
+ * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
115
+ * configured to wait until the answer to the question (`actual`) meets the `expectation`,
116
+ * or a custom timeout expires.
117
+ *
118
+ * @param {Duration} duration
119
+ * Custom timeout to override {@link Wait.Default_Timeout}
120
+ *
121
+ * @returns {WaitBuilder}
122
+ */
123
+ static upTo(duration) {
124
+ return {
125
+ until: (actual, expectation) => new WaitUntil(actual, expectation, duration),
126
+ };
127
+ }
128
+ /**
129
+ * @desc
130
+ * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
131
+ * configured to wait until the answer to the question (`actual`) meets the `expectation`,
132
+ * or a {@link Wait.Default_Timeout} expires.
133
+ *
134
+ * @param {Answerable<Actual>} actual
135
+ * A {@link @serenity-js/core/lib/screenplay~Question}
136
+ * that the {@link @serenity-js/core/lib/screenplay/actor~Actor}
137
+ * will keep asking until the answer meets
138
+ * the {@link @serenity-js/core/lib/screenplay/questions~Expectation} provided
139
+ *
140
+ * @param {@serenity-js/core/lib/screenplay/questions~<any,Actual>} expectation
141
+ * An {@link @serenity-js/core/lib/screenplay/questions~Expectation} to be met before proceeding
142
+ *
143
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
144
+ */
145
+ static until(actual, expectation) {
146
+ return new WaitUntil(actual, expectation, Wait.Default_Timeout);
147
+ }
148
+ }
149
+ exports.Wait = Wait;
150
+ /**
151
+ * @desc
152
+ * Default timeout of 5 seconds used with {@link Wait.until}.
153
+ *
154
+ * @type {@serenity-js/core~Duration}
155
+ */
156
+ Wait.Default_Timeout = core_1.Duration.ofSeconds(5);
157
+ /**
158
+ * @package
159
+ */
160
+ class WaitFor extends core_1.Interaction {
161
+ constructor(duration) {
162
+ super();
163
+ this.duration = duration;
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
+ * @returns {Promise<void>}
172
+ *
173
+ * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
174
+ * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
175
+ * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
176
+ */
177
+ async performAs(actor) {
178
+ return actor.answer(this.duration)
179
+ .then(duration => abilities_1.BrowseTheWeb.as(actor).waitFor(duration));
180
+ }
181
+ /**
182
+ * @desc
183
+ * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
184
+ *
185
+ * @returns {string}
186
+ */
187
+ toString() {
188
+ return (0, io_1.formatted) `#actor waits for ${this.duration}`;
189
+ }
190
+ }
191
+ /**
192
+ * @package
193
+ */
194
+ class WaitUntil extends core_1.Interaction {
195
+ constructor(actual, expectation, timeout) {
196
+ super();
197
+ this.actual = actual;
198
+ this.expectation = expectation;
199
+ this.timeout = timeout;
200
+ }
201
+ /**
202
+ * @desc
203
+ * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
204
+ * perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
205
+ *
206
+ * @param {UsesAbilities & AnswersQuestions} actor
207
+ * @returns {Promise<void>}
208
+ *
209
+ * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
210
+ * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
211
+ * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
212
+ */
213
+ performAs(actor) {
214
+ const actual = this.actual, expectation = this.expectation.answeredBy(actor);
215
+ let expectationOutcome;
216
+ return abilities_1.BrowseTheWeb.as(actor)
217
+ .waitUntil(function () {
218
+ return actor.answer(actual)
219
+ .then(act => expectation(act))
220
+ .then(outcome => {
221
+ expectationOutcome = outcome;
222
+ return outcome instanceof core_1.ExpectationMet;
223
+ });
224
+ }, this.timeout)
225
+ .catch(error => {
226
+ if (expectationOutcome) {
227
+ throw new core_1.AssertionError(`Waited ${this.timeout.toString()} for ${(0, io_1.formatted) `${this.actual}`} to ${this.expectation.toString()}`, expectationOutcome.expected, expectationOutcome.actual, error);
228
+ }
229
+ throw error;
230
+ });
231
+ }
232
+ /**
233
+ * @desc
234
+ * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
235
+ *
236
+ * @returns {string}
237
+ */
238
+ toString() {
239
+ return (0, io_1.formatted) `#actor waits up to ${this.timeout} until ${this.actual} does ${this.expectation}`;
240
+ }
241
+ }
242
+ //# sourceMappingURL=Wait.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wait.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Wait.ts"],"names":[],"mappings":";;;AAAA,4CAAwK;AACxK,iDAAqD;AAErD,4CAA4C;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,MAAa,IAAI;IAUb;;;;;;;;;;OAUG;IACH,MAAM,CAAC,GAAG,CAAC,QAA8B;QACrC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,IAAI,CAAC,QAAkB;QAC1B,OAAO;YACH,KAAK,EAAE,CAAS,MAA0B,EAAE,WAAqC,EAAe,EAAE,CAC9F,IAAI,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC;SACn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AAY,CAAC,EAAE,CAAC,KAAK,CAAC;aACxB,SAAS,CAAC;YACP,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;iBACtB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;iBAC7B,IAAI,CAAC,OAAO,CAAC,EAAE;gBACZ,kBAAkB,GAAG,OAAO,CAAC;gBAE7B,OAAO,OAAO,YAAY,qBAAc,CAAC;YAC7C,CAAC,CAAC,CAAC;QACX,CAAC,EACD,IAAI,CAAC,OAAO,CACX;aACA,KAAK,CAAC,KAAK,CAAC,EAAE;YACX,IAAI,kBAAkB,EAAE;gBACpB,MAAM,IAAI,qBAAc,CACpB,UAAW,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAG,QAAS,IAAA,cAAS,EAAC,GAAI,IAAI,CAAC,MAAO,EAAG,OAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAG,EAAE,EAC/G,kBAAkB,CAAC,QAAQ,EAC3B,kBAAkB,CAAC,MAAM,EACzB,KAAK,CACR,CAAC;aACL;YAED,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,IAAA,cAAS,EAAA,sBAAuB,IAAI,CAAC,OAAQ,UAAW,IAAI,CAAC,MAAO,SAAU,IAAI,CAAC,WAAY,EAAE,CAAC;IAC7G,CAAC;CACJ"}
@@ -0,0 +1,32 @@
1
+ import { Answerable, Expectation, Interaction } from '@serenity-js/core';
2
+ /**
3
+ * @desc
4
+ * Fluent interface to make the instantiation of
5
+ * the {@link @serenity-js/core/lib/screenplay~Interaction}
6
+ * to {@link Wait} more readable.
7
+ *
8
+ * @see {@link Wait}
9
+ *
10
+ * @interface
11
+ */
12
+ export interface WaitBuilder {
13
+ /**
14
+ * @desc
15
+ * Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
16
+ * to {@link Wait}.
17
+ *
18
+ * @param {Answerable<Actual>} actual
19
+ * A {@link @serenity-js/core/lib/screenplay~Question}
20
+ * that the {@link @serenity-js/core/lib/screenplay/actor~Actor}
21
+ * will keep asking until the answer meets
22
+ * the {@link @serenity-js/core/lib/screenplay/questions~Expectation} provided
23
+ *
24
+ * @param {@serenity-js/core/lib/screenplay/questions~Expectation<any,Actual>} expectation
25
+ * An {@link @serenity-js/assertions~Expectation} to be met before proceeding
26
+ *
27
+ * @returns {Interaction}
28
+ *
29
+ * @see {@link Target}
30
+ */
31
+ until: <Actual>(actual: Answerable<Actual>, expectation: Expectation<any, Actual>) => Interaction;
32
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=WaitBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WaitBuilder.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/WaitBuilder.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ export * from './Clear';
2
+ export * from './Click';
3
+ export * from './DoubleClick';
4
+ export * from './Enter';
5
+ export * from './ExecuteScript';
6
+ export * from './Hover';
7
+ export * from './Navigate';
8
+ export * from './Press';
9
+ export * from './PressBuilder';
10
+ export * from './RightClick';
11
+ export * from './Scroll';
12
+ export * from './Select';
13
+ export * from './SelectBuilder';
14
+ export * from './Switch';
15
+ export * from './TakeScreenshot';
16
+ export * from './Wait';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Clear"), exports);
14
+ __exportStar(require("./Click"), exports);
15
+ __exportStar(require("./DoubleClick"), exports);
16
+ __exportStar(require("./Enter"), exports);
17
+ __exportStar(require("./ExecuteScript"), exports);
18
+ __exportStar(require("./Hover"), exports);
19
+ __exportStar(require("./Navigate"), exports);
20
+ __exportStar(require("./Press"), exports);
21
+ __exportStar(require("./PressBuilder"), exports);
22
+ __exportStar(require("./RightClick"), exports);
23
+ __exportStar(require("./Scroll"), exports);
24
+ __exportStar(require("./Select"), exports);
25
+ __exportStar(require("./SelectBuilder"), exports);
26
+ __exportStar(require("./Switch"), exports);
27
+ __exportStar(require("./TakeScreenshot"), exports);
28
+ __exportStar(require("./Wait"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,0CAAwB;AACxB,gDAA8B;AAC9B,0CAAwB;AACxB,kDAAgC;AAChC,0CAAwB;AACxB,6CAA2B;AAC3B,0CAAwB;AACxB,iDAA+B;AAC/B,+CAA6B;AAC7B,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,2CAAyB;AACzB,mDAAiC;AACjC,yCAAuB"}
@@ -0,0 +1,117 @@
1
+ import { Adapter, Answerable, Interaction, Question, Timestamp } from '@serenity-js/core';
2
+ import { CookieData } from './CookieData';
3
+ export declare abstract class Cookie {
4
+ protected readonly cookieName: string;
5
+ /**
6
+ * @desc
7
+ * Creates a {@link @serenity-js/core/lib/screenplay~Question} about a Cookie
8
+ *
9
+ * @param {Answerable<string>} name
10
+ * @returns {Question<Promise<Cookie>> & Adapter<Cookie>}
11
+ */
12
+ static called(name: Answerable<string>): Question<Promise<Cookie>> & Adapter<Cookie>;
13
+ /**
14
+ * @desc
15
+ * Sets a cookie for the current page.
16
+ * Make sure that the actor performing this interaction is on the page that should receive the cookie.
17
+ * An actor can't set a cookie for an arbitrary page without being on that page.
18
+ *
19
+ * @param {Answerable<CookieData>} cookieData
20
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
21
+ */
22
+ static set(cookieData: Answerable<CookieData>): Interaction;
23
+ /**
24
+ * @desc
25
+ * Creates an {@link @serenity-js/core/lib/screenplay~Interaction} to delete all cookies currently set in the browser.
26
+ *
27
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
28
+ */
29
+ static deleteAll(): Interaction;
30
+ private cookie;
31
+ protected constructor(cookieName: string);
32
+ name(): string;
33
+ /**
34
+ * @desc
35
+ * Checks if a given cookie is set.
36
+ *
37
+ * @returns {Promise<boolean>}
38
+ */
39
+ isPresent(): Promise<boolean>;
40
+ /**
41
+ * @desc
42
+ * Returns the value of a given cookie.
43
+ *
44
+ * @returns {Promise<string>}
45
+ */
46
+ value(): Promise<string>;
47
+ /**
48
+ * @desc
49
+ * Returns the path of a given cookie, if any was set.
50
+ *
51
+ * @returns {Promise<string>}
52
+ */
53
+ path(): Promise<string>;
54
+ /**
55
+ * @desc
56
+ * Returns the domain of a given cookie, if any was set.
57
+ *
58
+ * @returns {Promise<string>}
59
+ */
60
+ domain(): Promise<string>;
61
+ /**
62
+ * @desc
63
+ * Checks if a given cookie is HTTP-only.
64
+ *
65
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies
66
+ *
67
+ * @returns {Promise<string>}
68
+ */
69
+ isHttpOnly(): Promise<boolean>;
70
+ /**
71
+ * @desc
72
+ * Checks if a given cookie is secure.
73
+ *
74
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies
75
+ *
76
+ * @returns {Promise<string>}
77
+ */
78
+ isSecure(): Promise<boolean>;
79
+ /**
80
+ * @desc
81
+ * Returns the expiry date of a given cookie
82
+ *
83
+ * @returns {Promise<Timestamp>}
84
+ */
85
+ expiry(): Promise<Timestamp>;
86
+ /**
87
+ * @desc
88
+ * Deletes a given cookie.
89
+ *
90
+ * @abstract
91
+ *
92
+ * @returns {Promise<void>}
93
+ */
94
+ abstract delete(): Promise<void>;
95
+ /**
96
+ * @desc
97
+ * Reads a given cookie from the browser.
98
+ *
99
+ * This method is to be implemented by integration tool-specific adapters.
100
+ * **Please note**: you don't need to implement any response caching here
101
+ * since it is covered by {@link Cookie#lazyLoadCookie} method.
102
+ *
103
+ * @protected
104
+ * @abstract
105
+ *
106
+ * @returns {Promise<void>}
107
+ */
108
+ protected abstract read(): Promise<CookieData>;
109
+ /**
110
+ * @desc
111
+ * Invokes {@link Cookie#read} and caches the result in memory.
112
+ *
113
+ * @private
114
+ * @returns {Promise<CookieData>}
115
+ */
116
+ private lazyLoadCookie;
117
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cookie = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const io_1 = require("@serenity-js/core/lib/io");
6
+ const tiny_types_1 = require("tiny-types");
7
+ const errors_1 = require("../../errors");
8
+ const abilities_1 = require("../abilities");
9
+ class Cookie {
10
+ constructor(cookieName) {
11
+ this.cookieName = cookieName;
12
+ (0, tiny_types_1.ensure)('browser', cookieName, (0, tiny_types_1.isDefined)());
13
+ }
14
+ /**
15
+ * @desc
16
+ * Creates a {@link @serenity-js/core/lib/screenplay~Question} about a Cookie
17
+ *
18
+ * @param {Answerable<string>} name
19
+ * @returns {Question<Promise<Cookie>> & Adapter<Cookie>}
20
+ */
21
+ static called(name) {
22
+ return core_1.Question.about(`"${name}" cookie`, async (actor) => {
23
+ const cookieName = await actor.answer(name);
24
+ return abilities_1.BrowseTheWeb.as(actor).cookie(cookieName);
25
+ });
26
+ }
27
+ /**
28
+ * @desc
29
+ * Sets a cookie for the current page.
30
+ * Make sure that the actor performing this interaction is on the page that should receive the cookie.
31
+ * An actor can't set a cookie for an arbitrary page without being on that page.
32
+ *
33
+ * @param {Answerable<CookieData>} cookieData
34
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
35
+ */
36
+ static set(cookieData) {
37
+ return core_1.Interaction.where((0, io_1.formatted) `#actor sets cookie: ${cookieData}`, async (actor) => {
38
+ const cookie = (0, tiny_types_1.ensure)('cookieData', await actor.answer(cookieData), (0, tiny_types_1.isDefined)(), (0, tiny_types_1.isPlainObject)());
39
+ const sanitisedCookieData = {
40
+ name: (0, tiny_types_1.ensure)(`Cookie.set(cookieData.name)`, cookie.name, (0, tiny_types_1.isDefined)(), (0, tiny_types_1.isString)()),
41
+ value: (0, tiny_types_1.ensure)(`Cookie.set(cookieData.value)`, cookie.value, (0, tiny_types_1.isDefined)(), (0, tiny_types_1.isString)()),
42
+ path: ensureIfPresent(cookie, 'path', (0, tiny_types_1.isString)()),
43
+ domain: ensureIfPresent(cookie, 'domain', (0, tiny_types_1.isString)()),
44
+ secure: ensureIfPresent(cookie, 'secure', (0, tiny_types_1.isBoolean)()),
45
+ httpOnly: ensureIfPresent(cookie, 'httpOnly', (0, tiny_types_1.isBoolean)()),
46
+ expiry: ensureIfPresent(cookie, 'expiry', (0, tiny_types_1.isInstanceOf)(core_1.Timestamp)),
47
+ sameSite: ensureIfPresent(cookie, 'sameSite', (0, tiny_types_1.isOneOf)('Lax', 'Strict', 'None')),
48
+ };
49
+ return abilities_1.BrowseTheWeb.as(actor).setCookie(sanitisedCookieData);
50
+ });
51
+ }
52
+ /**
53
+ * @desc
54
+ * Creates an {@link @serenity-js/core/lib/screenplay~Interaction} to delete all cookies currently set in the browser.
55
+ *
56
+ * @returns {@serenity-js/core/lib/screenplay~Interaction}
57
+ */
58
+ static deleteAll() {
59
+ return core_1.Interaction.where(`#actor deletes all cookies`, actor => {
60
+ return abilities_1.BrowseTheWeb.as(actor).deleteAllCookies();
61
+ });
62
+ }
63
+ name() {
64
+ return this.cookieName;
65
+ }
66
+ /**
67
+ * @desc
68
+ * Checks if a given cookie is set.
69
+ *
70
+ * @returns {Promise<boolean>}
71
+ */
72
+ async isPresent() {
73
+ try {
74
+ const cookie = await this.lazyLoadCookie();
75
+ return cookie && cookie.name === this.cookieName;
76
+ }
77
+ catch (error) {
78
+ if (error instanceof errors_1.CookieMissingError) {
79
+ return false;
80
+ }
81
+ throw error;
82
+ }
83
+ }
84
+ /**
85
+ * @desc
86
+ * Returns the value of a given cookie.
87
+ *
88
+ * @returns {Promise<string>}
89
+ */
90
+ async value() {
91
+ const cookie = await this.lazyLoadCookie();
92
+ return cookie.value;
93
+ }
94
+ /**
95
+ * @desc
96
+ * Returns the path of a given cookie, if any was set.
97
+ *
98
+ * @returns {Promise<string>}
99
+ */
100
+ async path() {
101
+ const cookie = await this.lazyLoadCookie();
102
+ return cookie.path;
103
+ }
104
+ /**
105
+ * @desc
106
+ * Returns the domain of a given cookie, if any was set.
107
+ *
108
+ * @returns {Promise<string>}
109
+ */
110
+ async domain() {
111
+ const cookie = await this.lazyLoadCookie();
112
+ return cookie.domain;
113
+ }
114
+ /**
115
+ * @desc
116
+ * Checks if a given cookie is HTTP-only.
117
+ *
118
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies
119
+ *
120
+ * @returns {Promise<string>}
121
+ */
122
+ async isHttpOnly() {
123
+ const cookie = await this.lazyLoadCookie();
124
+ return cookie.httpOnly;
125
+ }
126
+ /**
127
+ * @desc
128
+ * Checks if a given cookie is secure.
129
+ *
130
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies
131
+ *
132
+ * @returns {Promise<string>}
133
+ */
134
+ async isSecure() {
135
+ const cookie = await this.lazyLoadCookie();
136
+ return cookie.secure;
137
+ }
138
+ /**
139
+ * @desc
140
+ * Returns the expiry date of a given cookie
141
+ *
142
+ * @returns {Promise<Timestamp>}
143
+ */
144
+ async expiry() {
145
+ const cookie = await this.lazyLoadCookie();
146
+ return cookie.expiry;
147
+ }
148
+ /**
149
+ * @desc
150
+ * Invokes {@link Cookie#read} and caches the result in memory.
151
+ *
152
+ * @private
153
+ * @returns {Promise<CookieData>}
154
+ */
155
+ async lazyLoadCookie() {
156
+ if (!this.cookie) {
157
+ this.cookie = await this.read();
158
+ }
159
+ return this.cookie;
160
+ }
161
+ }
162
+ exports.Cookie = Cookie;
163
+ /**
164
+ * @ignore
165
+ * @private
166
+ *
167
+ * @param data
168
+ * @param property
169
+ * @param predicates
170
+ */
171
+ function ensureIfPresent(data, property, ...predicates) {
172
+ return data[property] !== undefined
173
+ ? (0, tiny_types_1.ensure)(`Cookie.set(cookieData.${property})`, data[property], ...predicates)
174
+ : undefined;
175
+ }
176
+ //# sourceMappingURL=Cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cookie.js","sourceRoot":"","sources":["../../../src/screenplay/models/Cookie.ts"],"names":[],"mappings":";;;AAAA,4CAA0F;AAC1F,iDAAqD;AACrD,2CAAqH;AAErH,yCAAkD;AAClD,4CAA4C;AAG5C,MAAsB,MAAM;IA2DxB,YAAyC,UAAkB;QAAlB,eAAU,GAAV,UAAU,CAAQ;QACvD,IAAA,mBAAM,EAAC,SAAS,EAAE,UAAU,EAAE,IAAA,sBAAS,GAAE,CAAC,CAAC;IAC/C,CAAC;IA3DD;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAwB;QAClC,OAAO,eAAQ,CAAC,KAAK,CAAC,IAAK,IAAK,UAAU,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACtD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC5C,OAAO,wBAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,CAAC,UAAkC;QAEzC,OAAO,kBAAW,CAAC,KAAK,CAAC,IAAA,cAAS,EAAC,uBAAwB,UAAW,EAAE,EAAE,K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