@serenity-js/webdriverio 2.32.3 → 3.0.0-rc.1

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 (240) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/lib/adapter/WebdriverIOFrameworkAdapter.js +1 -1
  3. package/lib/adapter/WebdriverIOFrameworkAdapter.js.map +1 -1
  4. package/lib/adapter/WebdriverIONotifier.d.ts +35 -1
  5. package/lib/adapter/WebdriverIONotifier.js +174 -13
  6. package/lib/adapter/WebdriverIONotifier.js.map +1 -1
  7. package/lib/index.d.ts +0 -3
  8. package/lib/index.js +0 -3
  9. package/lib/index.js.map +1 -1
  10. package/lib/screenplay/abilities/{BrowseTheWeb.d.ts → BrowseTheWebWithWebdriverIO.d.ts} +79 -23
  11. package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithWebdriverIO.js} +160 -25
  12. package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js.map +1 -0
  13. package/lib/screenplay/abilities/index.d.ts +1 -1
  14. package/lib/screenplay/abilities/index.js +1 -1
  15. package/lib/screenplay/abilities/index.js.map +1 -1
  16. package/lib/screenplay/index.d.ts +1 -2
  17. package/lib/screenplay/index.js +1 -2
  18. package/lib/screenplay/index.js.map +1 -1
  19. package/lib/screenplay/models/WebdriverIOCookie.d.ts +8 -0
  20. package/lib/screenplay/models/WebdriverIOCookie.js +39 -0
  21. package/lib/screenplay/models/WebdriverIOCookie.js.map +1 -0
  22. package/lib/screenplay/models/WebdriverIOModalDialog.d.ts +11 -0
  23. package/lib/screenplay/models/WebdriverIOModalDialog.js +40 -0
  24. package/lib/screenplay/models/WebdriverIOModalDialog.js.map +1 -0
  25. package/lib/screenplay/models/WebdriverIONativeElementRoot.d.ts +2 -0
  26. package/lib/screenplay/{interactions/EnterBuilder.js → models/WebdriverIONativeElementRoot.js} +1 -1
  27. package/lib/screenplay/models/WebdriverIONativeElementRoot.js.map +1 -0
  28. package/lib/screenplay/models/WebdriverIOPage.d.ts +24 -0
  29. package/lib/screenplay/models/WebdriverIOPage.js +98 -0
  30. package/lib/screenplay/models/WebdriverIOPage.js.map +1 -0
  31. package/lib/screenplay/models/WebdriverIOPageElement.d.ts +22 -0
  32. package/lib/screenplay/models/WebdriverIOPageElement.js +75 -0
  33. package/lib/screenplay/models/WebdriverIOPageElement.js.map +1 -0
  34. package/lib/screenplay/models/WebdriverIOPageElements.d.ts +15 -0
  35. package/lib/screenplay/models/WebdriverIOPageElements.js +65 -0
  36. package/lib/screenplay/models/WebdriverIOPageElements.js.map +1 -0
  37. package/lib/screenplay/models/index.d.ts +6 -0
  38. package/lib/{input → screenplay/models}/index.js +6 -1
  39. package/lib/screenplay/models/index.js.map +1 -0
  40. package/package.json +21 -31
  41. package/src/adapter/WebdriverIOFrameworkAdapter.ts +2 -0
  42. package/src/adapter/WebdriverIONotifier.ts +225 -23
  43. package/src/index.ts +0 -3
  44. package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithWebdriverIO.ts} +200 -31
  45. package/src/screenplay/abilities/index.ts +1 -1
  46. package/src/screenplay/index.ts +1 -2
  47. package/src/screenplay/models/WebdriverIOCookie.ts +44 -0
  48. package/src/screenplay/models/WebdriverIOModalDialog.ts +45 -0
  49. package/src/screenplay/models/WebdriverIONativeElementRoot.ts +3 -0
  50. package/src/screenplay/models/WebdriverIOPage.ts +120 -0
  51. package/src/screenplay/models/WebdriverIOPageElement.ts +92 -0
  52. package/src/screenplay/models/WebdriverIOPageElements.ts +91 -0
  53. package/src/screenplay/models/index.ts +6 -0
  54. package/lib/expectations/ElementExpectation.d.ts +0 -11
  55. package/lib/expectations/ElementExpectation.js +0 -27
  56. package/lib/expectations/ElementExpectation.js.map +0 -1
  57. package/lib/expectations/index.d.ts +0 -6
  58. package/lib/expectations/index.js +0 -19
  59. package/lib/expectations/index.js.map +0 -1
  60. package/lib/expectations/isActive.d.ts +0 -15
  61. package/lib/expectations/isActive.js +0 -21
  62. package/lib/expectations/isActive.js.map +0 -1
  63. package/lib/expectations/isClickable.d.ts +0 -20
  64. package/lib/expectations/isClickable.js +0 -26
  65. package/lib/expectations/isClickable.js.map +0 -1
  66. package/lib/expectations/isEnabled.d.ts +0 -14
  67. package/lib/expectations/isEnabled.js +0 -20
  68. package/lib/expectations/isEnabled.js.map +0 -1
  69. package/lib/expectations/isPresent.d.ts +0 -15
  70. package/lib/expectations/isPresent.js +0 -21
  71. package/lib/expectations/isPresent.js.map +0 -1
  72. package/lib/expectations/isSelected.d.ts +0 -14
  73. package/lib/expectations/isSelected.js +0 -20
  74. package/lib/expectations/isSelected.js.map +0 -1
  75. package/lib/expectations/isVisible.d.ts +0 -14
  76. package/lib/expectations/isVisible.js +0 -20
  77. package/lib/expectations/isVisible.js.map +0 -1
  78. package/lib/input/Key.d.ts +0 -73
  79. package/lib/input/Key.js +0 -84
  80. package/lib/input/Key.js.map +0 -1
  81. package/lib/input/index.d.ts +0 -1
  82. package/lib/input/index.js.map +0 -1
  83. package/lib/screenplay/abilities/BrowseTheWeb.js.map +0 -1
  84. package/lib/screenplay/interactions/Clear.d.ts +0 -79
  85. package/lib/screenplay/interactions/Clear.js +0 -97
  86. package/lib/screenplay/interactions/Clear.js.map +0 -1
  87. package/lib/screenplay/interactions/Click.d.ts +0 -73
  88. package/lib/screenplay/interactions/Click.js +0 -84
  89. package/lib/screenplay/interactions/Click.js.map +0 -1
  90. package/lib/screenplay/interactions/DoubleClick.d.ts +0 -90
  91. package/lib/screenplay/interactions/DoubleClick.js +0 -101
  92. package/lib/screenplay/interactions/DoubleClick.js.map +0 -1
  93. package/lib/screenplay/interactions/Enter.d.ts +0 -73
  94. package/lib/screenplay/interactions/Enter.js +0 -87
  95. package/lib/screenplay/interactions/Enter.js.map +0 -1
  96. package/lib/screenplay/interactions/EnterBuilder.d.ts +0 -25
  97. package/lib/screenplay/interactions/EnterBuilder.js.map +0 -1
  98. package/lib/screenplay/interactions/ExecuteScript.d.ts +0 -206
  99. package/lib/screenplay/interactions/ExecuteScript.js +0 -311
  100. package/lib/screenplay/interactions/ExecuteScript.js.map +0 -1
  101. package/lib/screenplay/interactions/Hover.d.ts +0 -78
  102. package/lib/screenplay/interactions/Hover.js +0 -89
  103. package/lib/screenplay/interactions/Hover.js.map +0 -1
  104. package/lib/screenplay/interactions/Navigate.d.ts +0 -141
  105. package/lib/screenplay/interactions/Navigate.js +0 -197
  106. package/lib/screenplay/interactions/Navigate.js.map +0 -1
  107. package/lib/screenplay/interactions/Press.d.ts +0 -84
  108. package/lib/screenplay/interactions/Press.js +0 -152
  109. package/lib/screenplay/interactions/Press.js.map +0 -1
  110. package/lib/screenplay/interactions/PressBuilder.d.ts +0 -26
  111. package/lib/screenplay/interactions/PressBuilder.js +0 -3
  112. package/lib/screenplay/interactions/PressBuilder.js.map +0 -1
  113. package/lib/screenplay/interactions/RightClick.d.ts +0 -89
  114. package/lib/screenplay/interactions/RightClick.js +0 -100
  115. package/lib/screenplay/interactions/RightClick.js.map +0 -1
  116. package/lib/screenplay/interactions/Scroll.d.ts +0 -75
  117. package/lib/screenplay/interactions/Scroll.js +0 -86
  118. package/lib/screenplay/interactions/Scroll.js.map +0 -1
  119. package/lib/screenplay/interactions/Wait.d.ts +0 -143
  120. package/lib/screenplay/interactions/Wait.js +0 -247
  121. package/lib/screenplay/interactions/Wait.js.map +0 -1
  122. package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -32
  123. package/lib/screenplay/interactions/WaitBuilder.js +0 -3
  124. package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
  125. package/lib/screenplay/interactions/WebElementInteraction.d.ts +0 -37
  126. package/lib/screenplay/interactions/WebElementInteraction.js +0 -52
  127. package/lib/screenplay/interactions/WebElementInteraction.js.map +0 -1
  128. package/lib/screenplay/interactions/index.d.ts +0 -13
  129. package/lib/screenplay/interactions/index.js +0 -26
  130. package/lib/screenplay/interactions/index.js.map +0 -1
  131. package/lib/screenplay/questions/Attribute.d.ts +0 -82
  132. package/lib/screenplay/questions/Attribute.js +0 -102
  133. package/lib/screenplay/questions/Attribute.js.map +0 -1
  134. package/lib/screenplay/questions/CSSClasses.d.ts +0 -92
  135. package/lib/screenplay/questions/CSSClasses.js +0 -112
  136. package/lib/screenplay/questions/CSSClasses.js.map +0 -1
  137. package/lib/screenplay/questions/LastScriptExecution.d.ts +0 -14
  138. package/lib/screenplay/questions/LastScriptExecution.js +0 -22
  139. package/lib/screenplay/questions/LastScriptExecution.js.map +0 -1
  140. package/lib/screenplay/questions/NestedTargetBuilder.d.ts +0 -27
  141. package/lib/screenplay/questions/NestedTargetBuilder.js +0 -3
  142. package/lib/screenplay/questions/NestedTargetBuilder.js.map +0 -1
  143. package/lib/screenplay/questions/TargetBuilder.d.ts +0 -25
  144. package/lib/screenplay/questions/TargetBuilder.js +0 -3
  145. package/lib/screenplay/questions/TargetBuilder.js.map +0 -1
  146. package/lib/screenplay/questions/Text.d.ts +0 -95
  147. package/lib/screenplay/questions/Text.js +0 -130
  148. package/lib/screenplay/questions/Text.js.map +0 -1
  149. package/lib/screenplay/questions/Value.d.ts +0 -63
  150. package/lib/screenplay/questions/Value.js +0 -78
  151. package/lib/screenplay/questions/Value.js.map +0 -1
  152. package/lib/screenplay/questions/Website.d.ts +0 -21
  153. package/lib/screenplay/questions/Website.js +0 -31
  154. package/lib/screenplay/questions/Website.js.map +0 -1
  155. package/lib/screenplay/questions/index.d.ts +0 -10
  156. package/lib/screenplay/questions/index.js +0 -23
  157. package/lib/screenplay/questions/index.js.map +0 -1
  158. package/lib/screenplay/questions/lists.d.ts +0 -86
  159. package/lib/screenplay/questions/lists.js +0 -137
  160. package/lib/screenplay/questions/lists.js.map +0 -1
  161. package/lib/screenplay/questions/locators.d.ts +0 -196
  162. package/lib/screenplay/questions/locators.js +0 -219
  163. package/lib/screenplay/questions/locators.js.map +0 -1
  164. package/lib/screenplay/questions/targets.d.ts +0 -254
  165. package/lib/screenplay/questions/targets.js +0 -334
  166. package/lib/screenplay/questions/targets.js.map +0 -1
  167. package/lib/stage/crew/index.d.ts +0 -1
  168. package/lib/stage/crew/index.js +0 -14
  169. package/lib/stage/crew/index.js.map +0 -1
  170. package/lib/stage/crew/photographer/Photographer.d.ts +0 -83
  171. package/lib/stage/crew/photographer/Photographer.js +0 -102
  172. package/lib/stage/crew/photographer/Photographer.js.map +0 -1
  173. package/lib/stage/crew/photographer/index.d.ts +0 -2
  174. package/lib/stage/crew/photographer/index.js +0 -15
  175. package/lib/stage/crew/photographer/index.js.map +0 -1
  176. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +0 -28
  177. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +0 -65
  178. package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +0 -1
  179. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +0 -18
  180. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +0 -30
  181. package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +0 -1
  182. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +0 -17
  183. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +0 -28
  184. package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +0 -1
  185. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +0 -19
  186. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +0 -28
  187. package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +0 -1
  188. package/lib/stage/crew/photographer/strategies/index.d.ts +0 -4
  189. package/lib/stage/crew/photographer/strategies/index.js +0 -17
  190. package/lib/stage/crew/photographer/strategies/index.js.map +0 -1
  191. package/lib/stage/index.d.ts +0 -1
  192. package/lib/stage/index.js +0 -14
  193. package/lib/stage/index.js.map +0 -1
  194. package/src/expectations/ElementExpectation.ts +0 -31
  195. package/src/expectations/index.ts +0 -6
  196. package/src/expectations/isActive.ts +0 -21
  197. package/src/expectations/isClickable.ts +0 -26
  198. package/src/expectations/isEnabled.ts +0 -19
  199. package/src/expectations/isPresent.ts +0 -20
  200. package/src/expectations/isSelected.ts +0 -19
  201. package/src/expectations/isVisible.ts +0 -19
  202. package/src/input/Key.ts +0 -83
  203. package/src/input/index.ts +0 -1
  204. package/src/screenplay/interactions/Clear.ts +0 -102
  205. package/src/screenplay/interactions/Click.ts +0 -85
  206. package/src/screenplay/interactions/DoubleClick.ts +0 -102
  207. package/src/screenplay/interactions/Enter.ts +0 -93
  208. package/src/screenplay/interactions/EnterBuilder.ts +0 -27
  209. package/src/screenplay/interactions/ExecuteScript.ts +0 -344
  210. package/src/screenplay/interactions/Hover.ts +0 -90
  211. package/src/screenplay/interactions/Navigate.ts +0 -208
  212. package/src/screenplay/interactions/Press.ts +0 -172
  213. package/src/screenplay/interactions/PressBuilder.ts +0 -28
  214. package/src/screenplay/interactions/RightClick.ts +0 -100
  215. package/src/screenplay/interactions/Scroll.ts +0 -87
  216. package/src/screenplay/interactions/Wait.ts +0 -267
  217. package/src/screenplay/interactions/WaitBuilder.ts +0 -34
  218. package/src/screenplay/interactions/WebElementInteraction.ts +0 -56
  219. package/src/screenplay/interactions/index.ts +0 -13
  220. package/src/screenplay/questions/Attribute.ts +0 -112
  221. package/src/screenplay/questions/CSSClasses.ts +0 -116
  222. package/src/screenplay/questions/LastScriptExecution.ts +0 -21
  223. package/src/screenplay/questions/NestedTargetBuilder.ts +0 -30
  224. package/src/screenplay/questions/TargetBuilder.ts +0 -27
  225. package/src/screenplay/questions/Text.ts +0 -140
  226. package/src/screenplay/questions/Value.ts +0 -82
  227. package/src/screenplay/questions/Website.ts +0 -34
  228. package/src/screenplay/questions/index.ts +0 -10
  229. package/src/screenplay/questions/lists.ts +0 -161
  230. package/src/screenplay/questions/locators.ts +0 -254
  231. package/src/screenplay/questions/targets.ts +0 -401
  232. package/src/stage/crew/index.ts +0 -1
  233. package/src/stage/crew/photographer/Photographer.ts +0 -108
  234. package/src/stage/crew/photographer/index.ts +0 -2
  235. package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +0 -103
  236. package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +0 -28
  237. package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +0 -26
  238. package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +0 -26
  239. package/src/stage/crew/photographer/strategies/index.ts +0 -4
  240. package/src/stage/index.ts +0 -1
@@ -1,267 +0,0 @@
1
- import { Answerable, AnswersQuestions, AssertionError, Duration, Expectation, ExpectationMet, ExpectationOutcome, Interaction, UsesAbilities } from '@serenity-js/core';
2
- import { formatted } from '@serenity-js/core/lib/io';
3
-
4
- import { BrowseTheWeb } from '../abilities';
5
- import { WaitBuilder } from './WaitBuilder';
6
-
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
- export class Wait {
98
-
99
- /**
100
- * @desc
101
- * Default timeout of 5 seconds used with {@link Wait.until}.
102
- *
103
- * @type {@serenity-js/core~Duration}
104
- */
105
- static readonly Default_Timeout = Duration.ofSeconds(5);
106
-
107
- /**
108
- * @desc
109
- * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
110
- * configured to wait for a set duration.
111
- *
112
- * @param {Answerable<Duration>} duration
113
- * A set duration the {@link @serenity-js/core/lib/screenplay/actor~Actor} should wait for
114
- * before proceeding
115
- *
116
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
117
- */
118
- static for(duration: Answerable<Duration>): Interaction {
119
- return new WaitFor(duration);
120
- }
121
-
122
- /**
123
- * @desc
124
- * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
125
- * configured to wait until the answer to the question (`actual`) meets the `expectation`,
126
- * or a custom timeout expires.
127
- *
128
- * @param {Duration} duration
129
- * Custom timeout to override {@link Wait.Default_Timeout}
130
- *
131
- * @returns {WaitBuilder}
132
- */
133
- static upTo(duration: Duration): WaitBuilder {
134
- return {
135
- until: <Actual>(actual: Answerable<Actual>, expectation: Expectation<any, Actual>): Interaction =>
136
- new WaitUntil(actual, expectation, duration),
137
- };
138
- }
139
-
140
- /**
141
- * @desc
142
- * Instantiates a version of this {@link @serenity-js/core/lib/screenplay~Interaction}
143
- * configured to wait until the answer to the question (`actual`) meets the `expectation`,
144
- * or a {@link Wait.Default_Timeout} expires.
145
- *
146
- * @param {Answerable<Actual>} actual
147
- * A {@link @serenity-js/core/lib/screenplay~Question}
148
- * that the {@link @serenity-js/core/lib/screenplay/actor~Actor}
149
- * will keep asking until the answer meets
150
- * the {@link @serenity-js/core/lib/screenplay/questions~Expectation} provided
151
- *
152
- * @param {@serenity-js/core/lib/screenplay/questions~<any,Actual>} expectation
153
- * An {@link @serenity-js/core/lib/screenplay/questions~Expectation} to be met before proceeding
154
- *
155
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
156
- */
157
- static until<Actual>(actual: Answerable<Actual>, expectation: Expectation<any, Actual>): Interaction {
158
- return new WaitUntil(actual, expectation, Wait.Default_Timeout);
159
- }
160
- }
161
-
162
- /**
163
- * @package
164
- */
165
- class WaitFor extends Interaction {
166
- constructor(private readonly duration: Answerable<Duration>) {
167
- super();
168
- }
169
-
170
- /**
171
- * @desc
172
- * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
173
- * perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
174
- *
175
- * @param {UsesAbilities & AnswersQuestions} actor
176
- * @returns {Promise<void>}
177
- *
178
- * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
179
- * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
180
- * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
181
- */
182
- async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
183
- return actor.answer(this.duration)
184
- .then(duration => BrowseTheWeb.as(actor).browser.pause(duration.inMilliseconds()) as Promise<void>);
185
- }
186
-
187
- /**
188
- * @desc
189
- * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
190
- *
191
- * @returns {string}
192
- */
193
- toString(): string {
194
- return formatted`#actor waits for ${ this.duration }`;
195
- }
196
- }
197
-
198
- /**
199
- * @package
200
- */
201
- class WaitUntil<Actual> extends Interaction {
202
- constructor(
203
- private readonly actual: Answerable<Actual>,
204
- private readonly expectation: Expectation<any, Actual>,
205
- private readonly timeout: Duration,
206
- ) {
207
- super();
208
- }
209
-
210
- /**
211
- * @desc
212
- * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
213
- * perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
214
- *
215
- * @param {UsesAbilities & AnswersQuestions} actor
216
- * @returns {Promise<void>}
217
- *
218
- * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
219
- * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
220
- * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
221
- */
222
- performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> {
223
- const
224
- actual = this.actual,
225
- expectation = this.expectation.answeredBy(actor);
226
-
227
- let expectationOutcome: ExpectationOutcome<any, Actual>;
228
-
229
- return BrowseTheWeb.as(actor)
230
- .browser
231
- .waitUntil(function () {
232
- return actor.answer(actual)
233
- .then(act => expectation(act))
234
- .then(outcome => {
235
- expectationOutcome = outcome;
236
-
237
- return outcome instanceof ExpectationMet;
238
- });
239
- }, {
240
- timeout: this.timeout.inMilliseconds(),
241
- timeoutMsg: `Wait timed out after ${ this.timeout }`,
242
- })
243
- .then(_ => void 0)
244
- .catch(error => {
245
- if (expectationOutcome) {
246
- throw new AssertionError(
247
- `Waited ${ this.timeout.toString() } for ${ formatted `${ this.actual }` } to ${ this.expectation.toString() }`,
248
- expectationOutcome.expected,
249
- expectationOutcome.actual,
250
- error,
251
- );
252
- }
253
-
254
- throw error;
255
- });
256
- }
257
-
258
- /**
259
- * @desc
260
- * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
261
- *
262
- * @returns {string}
263
- */
264
- toString(): string {
265
- return formatted`#actor waits up to ${ this.timeout } until ${ this.actual } does ${ this.expectation }`;
266
- }
267
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * @desc
3
- * Fluent interface to make the instantiation of
4
- * the {@link @serenity-js/core/lib/screenplay~Interaction}
5
- * to {@link Wait} more readable.
6
- *
7
- * @see {@link Wait}
8
- *
9
- * @interface
10
- */
11
- import { Answerable, Expectation, Interaction } from '@serenity-js/core';
12
-
13
- export interface WaitBuilder {
14
-
15
- /**
16
- * @desc
17
- * Instantiates an {@link @serenity-js/core/lib/screenplay~Interaction}
18
- * to {@link Wait}.
19
- *
20
- * @param {Answerable<Actual>} actual
21
- * A {@link @serenity-js/core/lib/screenplay~Question}
22
- * that the {@link @serenity-js/core/lib/screenplay/actor~Actor}
23
- * will keep asking until the answer meets
24
- * the {@link @serenity-js/core/lib/screenplay/questions~Expectation} provided
25
- *
26
- * @param {@serenity-js/core/lib/screenplay/questions~Expectation<any,Actual>} expectation
27
- * An {@link @serenity-js/assertions~Expectation} to be met before proceeding
28
- *
29
- * @returns {Interaction}
30
- *
31
- * @see {@link Target}
32
- */
33
- until: <Actual>(actual: Answerable<Actual>, expectation: Expectation<any, Actual>) => Interaction;
34
- }
@@ -1,56 +0,0 @@
1
- import { Answerable, AnswersQuestions, Interaction, LogicError } from '@serenity-js/core';
2
- import { formatted } from '@serenity-js/core/lib/io';
3
- import { Element } from 'webdriverio';
4
-
5
- /**
6
- * @desc
7
- * A base class for WebdriverIO-specific interactions
8
- *
9
- * @extends {@serenity-js/core/lib/screenplay~Interaction}
10
- */
11
- export abstract class WebElementInteraction extends Interaction {
12
-
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
- constructor(private readonly description: string) {
19
- super();
20
- }
21
-
22
- /**
23
- * @desc
24
- * Returns the resolved {@link @wdio/types~Element}, or throws a {@link @serenity-js/core/lib/errors~LogicError}
25
- * if the element is `undefined`.
26
- *
27
- * @param {@serenity-js/core/lib/screenplay/actor~AnswersQuestions} actor
28
- * @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} element
29
- *
30
- * @returns {Promise<Element<'async'>>}
31
- *
32
- * @protected
33
- */
34
- protected async resolve(
35
- actor: AnswersQuestions,
36
- element: Answerable<Element<'async'>>,
37
- ): Promise<Element<'async'>> {
38
- const resolved = await actor.answer(element);
39
-
40
- if (! resolved) {
41
- throw new LogicError(formatted `Couldn't find ${ element }`);
42
- }
43
-
44
- return resolved;
45
- }
46
-
47
- /**
48
- * @desc
49
- * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
50
- *
51
- * @returns {string}
52
- */
53
- toString(): string {
54
- return this.description;
55
- }
56
- }
@@ -1,13 +0,0 @@
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 './Wait';
13
- export * from './WebElementInteraction';
@@ -1,112 +0,0 @@
1
- import { Answerable, AnswersQuestions, LogicError, MetaQuestion, Question, UsesAbilities } from '@serenity-js/core';
2
- import { Element } from 'webdriverio';
3
-
4
- import { TargetNestedElement } from './targets';
5
-
6
- /**
7
- * @desc
8
- * Returns the value of the given HTML attribute of a given {@link WebElement},
9
- * represented by Answerable<{@link @wdio/types~Element}>
10
- *
11
- * @example <caption>Example widget</caption>
12
- * <ul id="shopping-list" data-items-left="2">
13
- * <li data-state="bought">Coffee<li>
14
- * <li data-state="buy">Honey<li>
15
- * <li data-state="buy">Chocolate<li>
16
- * </ul>
17
- *
18
- * @example <caption>Retrieve a HTML attribute of a given WebElement</caption>
19
- * import { actorCalled } from '@serenity-js/core';
20
- * import { Ensure, equals } from '@serenity-js/assertions';
21
- * import { Attribute, by, BrowseTheWeb, Target } from '@serenity-js/webdriverio';
22
- *
23
- * const shoppingList = () =>
24
- * Target.the('shopping list').located(by.id('shopping-list'))
25
- *
26
- * actorCalled('Lisa')
27
- * .whoCan(BrowseTheWeb.using(browser))
28
- * .attemptsTo(
29
- * Ensure.that(Attribute.called('data-items-left').of(shoppingList()), equals('2')),
30
- * )
31
- *
32
- * @example <caption>Find WebElements with a given attribute</caption>
33
- * import { actorCalled } from '@serenity-js/core';
34
- * import { Ensure, includes } from '@serenity-js/assertions';
35
- * import { Attribute, BrowseTheWeb, by, Target } from '@serenity-js/webdriverio';
36
- *
37
- * class ShoppingList {
38
- * static items = () =>
39
- * Target.all('items')
40
- * .located(by.css('#shopping-list li'))
41
- *
42
- * static outstandingItems = () =>
43
- * ShoppingList.items
44
- * .where(Attribute.called('data-state'), includes('buy'))
45
- * }
46
- *
47
- * actorCalled('Lisa')
48
- * .whoCan(BrowseTheWeb.using(browser))
49
- * .attemptsTo(
50
- * Ensure.that(
51
- * Text.ofAll(ShoppingList.outstandingItems()),
52
- * equals([ 'Honey', 'Chocolate' ])
53
- * ),
54
- * )
55
- *
56
- * @extends {@serenity-js/core/lib/screenplay~Question}
57
- * @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
58
- */
59
- export class Attribute
60
- extends Question<Promise<string>>
61
- implements MetaQuestion<Answerable<Element<'async'>>, Promise<string>>
62
- {
63
- /**
64
- * @param {Answerable<string>} name
65
- * @returns {Attribute}
66
- */
67
- static called(name: Answerable<string>): Attribute {
68
- return new Attribute(name);
69
- }
70
-
71
- /**
72
- * @param {Answerable<string>} name
73
- * @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} [element]
74
- */
75
- constructor(
76
- private readonly name: Answerable<string>,
77
- private readonly element?: Answerable<Element<'async'>>,
78
- ) {
79
- super(`"${ name }" attribute of ${ element }`);
80
- }
81
-
82
- /**
83
- * @desc
84
- * Resolves to the value of a HTML attribute of the `target` element,
85
- * located in the context of a `parent` element.
86
- *
87
- * @param {Answerable<Element<'async'>>} parent
88
- * @returns {Question<Promise<string[]>>}
89
- *
90
- * @see {@link Target.all}
91
- * @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
92
- */
93
- of(parent: Answerable<Element<'async'>>): Question<Promise<string>> {
94
- return new Attribute(
95
- this.name,
96
- this.element
97
- ? new TargetNestedElement(parent, this.element)
98
- : parent
99
- );
100
- }
101
-
102
- async answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string> {
103
- if (! this.element) {
104
- throw new LogicError(`Target not specified`); // todo: better error message?
105
- }
106
-
107
- const element = await actor.answer(this.element);
108
- const name = await actor.answer(this.name);
109
-
110
- return element.getAttribute(name);
111
- }
112
- }
@@ -1,116 +0,0 @@
1
- import { Answerable, AnswersQuestions, MetaQuestion, Question, UsesAbilities } from '@serenity-js/core';
2
- import { formatted } from '@serenity-js/core/lib/io';
3
- import { Element } from 'webdriverio';
4
-
5
- import { Attribute } from './Attribute';
6
- import { TargetNestedElement } from './targets';
7
-
8
- /**
9
- * @desc
10
- * Resolves to an array of [CSS classes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#attr-class)
11
- * of a given {@link WebElement}, represented by Answerable<{@link @wdio/types~Element}>.
12
- *
13
- * @example <caption>Example widget</caption>
14
- * <ul id="shopping-list" class="active favourite">
15
- * <li class="bought">Coffee<li>
16
- * <li class="buy">Honey<li>
17
- * <li class="buy">Chocolate<li>
18
- * </ul>
19
- *
20
- * @example <caption>Retrieve CSS classes of a given WebElement</caption>
21
- * import { actorCalled } from '@serenity-js/core';
22
- * import { Ensure, equals } from '@serenity-js/assertions';
23
- * import { BrowseTheWeb, by, CSSClasses, Target } from '@serenity-js/webdriverio';
24
- *
25
- * const shoppingList = () =>
26
- * Target.the('shopping list').located(by.id('shopping-list'))
27
- *
28
- * actorCalled('Lisa')
29
- * .whoCan(BrowseTheWeb.using(browser))
30
- * .attemptsTo(
31
- * Ensure.that(CSSClasses.of(shoppingList()), equals([ 'active', 'favourite' ])),
32
- * )
33
- *
34
- * @example <caption>Find WebElements with a given class</caption>
35
- * import { actorCalled } from '@serenity-js/core';
36
- * import { Ensure, contain } from '@serenity-js/assertions';
37
- * import { BrowseTheWeb, by, CSSClasses, Target } from '@serenity-js/webdriverio';
38
- *
39
- * class ShoppingList {
40
- * static items = () =>
41
- * Target.all('items')
42
- * .located(by.css('#shopping-list li'))
43
- *
44
- * static outstandingItems = () =>
45
- * ShoppingList.items
46
- * .where(CSSClasses, contain('buy'))
47
- * }
48
- *
49
- * actorCalled('Lisa')
50
- * .whoCan(BrowseTheWeb.using(browser))
51
- * .attemptsTo(
52
- * Ensure.that(
53
- * Text.ofAll(ShoppingList.outstandingItems()),
54
- * equals([ 'Honey', 'Chocolate' ])
55
- * ),
56
- * )
57
- *
58
- * @extends {@serenity-js/core/lib/screenplay~Question}
59
- * @implements {@serenity-js/core/lib/screenplay/questions~MetaQuestion}
60
- */
61
- export class CSSClasses
62
- extends Question<Promise<string[]>>
63
- implements MetaQuestion<Answerable<Element<'async'>>, Promise<string[]>>
64
- {
65
- /**
66
- * @param {Question<Element<'async'>> | Element<'async'>} target
67
- * @returns {CSSClasses}
68
- */
69
- static of(target: Answerable<Element<'async'>>): CSSClasses {
70
- return new CSSClasses(target);
71
- }
72
-
73
- /**
74
- * @param {Question<Element<'async'>> | Element<'async'>} target
75
- */
76
- constructor(private readonly target: Answerable<Element<'async'>>) {
77
- super(formatted `CSS classes of ${ target}`);
78
- }
79
-
80
- /**
81
- * @desc
82
- * Resolves to an array of CSS classes of the `target` element,
83
- * located in the context of a `parent` element.
84
- *
85
- * @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} parent
86
- * @returns {Question<Promise<string[]>>}
87
- *
88
- * @see {@link Target.all}
89
- * @see {@link @serenity-js/core/lib/screenplay/questions~MetaQuestion}
90
- */
91
- of(parent: Answerable<Element<'async'>>): Question<Promise<string[]>> {
92
- return new CSSClasses(new TargetNestedElement(parent, this.target));
93
- }
94
-
95
- /**
96
- * @desc
97
- * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
98
- * answer this {@link @serenity-js/core/lib/screenplay~Question}.
99
- *
100
- * @param {AnswersQuestions & UsesAbilities} actor
101
- * @returns {Promise<void>}
102
- *
103
- * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
104
- * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
105
- * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
106
- */
107
- answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<string[]> {
108
- return Attribute.called('class').of(this.target).answeredBy(actor)
109
- .then(attribute => attribute
110
- .replace(/\s+/, ' ')
111
- .trim()
112
- .split(' ')
113
- .filter(cssClass => !! cssClass),
114
- );
115
- }
116
- }
@@ -1,21 +0,0 @@
1
- import { Question } from '@serenity-js/core';
2
-
3
- import { BrowseTheWeb } from '../abilities';
4
-
5
- /**
6
- * @desc
7
- * Returns the result of last script executed via {@link ExecuteScript}
8
- */
9
- export class LastScriptExecution {
10
-
11
- /**
12
- * @desc
13
- * Enables asserting on the result of a function executed via {@link ExecuteScript}.
14
- *
15
- * @returns {Question<R>}
16
- */
17
- static result<R>(): Question<R> {
18
- return Question.about(`last script execution result`, actor =>
19
- BrowseTheWeb.as(actor).getLastScriptExecutionResult());
20
- }
21
- }
@@ -1,30 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import type { Element } from 'webdriverio';
3
-
4
- import { TargetBuilder } from './TargetBuilder';
5
-
6
- /**
7
- * @desc
8
- * Fluent interface to make the instantiation of
9
- * the {@link @serenity-js/core/lib/screenplay~Question}
10
- * about a nested {@link Target} more readable.
11
- *
12
- * @see {@link Target}
13
- *
14
- * @interface
15
- */
16
- export interface NestedTargetBuilder<T> {
17
-
18
- /**
19
- * @desc
20
- * Instantiates a {@link @serenity-js/core/lib/screenplay~Question}
21
- * about a {@link Target}.
22
- *
23
- * @param {@serenity-js/core/lib/screenplay~Answerable<Element<'async'>>} parent
24
- * @returns {TargetBuilder}
25
- *
26
- * @see {@link Target}
27
- * @see {@link TargetBuilder}
28
- */
29
- of: (parent: Answerable<Element<'async'>>) => TargetBuilder<T>;
30
- }
@@ -1,27 +0,0 @@
1
- import { Locator } from './locators';
2
-
3
- /**
4
- * @desc
5
- * Fluent interface to make the instantiation of
6
- * the {@link @serenity-js/core/lib/screenplay~Question}
7
- * about a {@link Target} more readable.
8
- *
9
- * @see {@link Target}
10
- *
11
- * @interface
12
- */
13
- export interface TargetBuilder<T> {
14
-
15
- /**
16
- * @desc
17
- * Instantiates a {@link @serenity-js/core/lib/screenplay~Question}
18
- * about a {@link Target}.
19
- *
20
- * @param {Locator} locator
21
- * @returns {@serenity-js/core/lib/screenplay~Question}
22
- *
23
- * @see {@link Target}
24
- * @see {@link Locator}
25
- */
26
- located: (locator: Locator) => T;
27
- }