@serenity-js/webdriverio 2.32.4 → 3.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +18 -28
  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,6 +1,7 @@
1
- import { Ability, UsesAbilities } from '@serenity-js/core';
2
- import type { Browser } from 'webdriverio';
3
- import { Key } from '../../input';
1
+ import { Duration, UsesAbilities } from '@serenity-js/core';
2
+ import { BrowserCapabilities, BrowseTheWeb, Cookie, CookieData, Key, ModalDialog, Page, PageElement } from '@serenity-js/web';
3
+ import type * as wdio from 'webdriverio';
4
+ import { WebdriverIOPageElement, WebdriverIOPageElements } from '../models';
4
5
  /**
5
6
  * @desc
6
7
  * An {@link @serenity-js/core/lib/screenplay~Ability} that enables the {@link @serenity-js/core/lib/screenplay/actor~Actor}
@@ -10,8 +11,6 @@ import { Key } from '../../input';
10
11
  * This means that its interface can change without affecting the major version of Serenity/JS itself.
11
12
  * In particular, please don't rely on the `browser` field to remain `public` in future releases.
12
13
  *
13
- * @experimental
14
- *
15
14
  * @example <caption>Using the WebdriverIO browser</caption>
16
15
  * import { Actor } from '@serenity-js/core';
17
16
  * import { BrowseTheWeb, by, Navigate, Target } from '@serenity-js/webdriverio'
@@ -36,31 +35,64 @@ import { Key } from '../../input';
36
35
  * @implements {@serenity-js/core/lib/screenplay~Ability}
37
36
  * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
38
37
  */
39
- export declare class BrowseTheWeb implements Ability {
40
- readonly browser: Browser<'async'>;
41
- /**
42
- * @private
43
- */
44
- private lastScriptExecutionSummary;
38
+ export declare class BrowseTheWebWithWebdriverIO extends BrowseTheWeb {
39
+ readonly browser: wdio.Browser<'async'>;
45
40
  /**
46
41
  * @param {@wdio/types~Browser} browserInstance
47
- * @returns {BrowseTheWeb}
42
+ * @returns {BrowseTheWebWithWebdriverIO}
48
43
  */
49
- static using(browserInstance: Browser<'async'>): BrowseTheWeb;
44
+ static using(browserInstance: wdio.Browser<'async'>): BrowseTheWebWithWebdriverIO;
50
45
  /**
51
46
  * @desc
52
- * Used to access the Actor's ability to {@link BrowseTheWeb}
47
+ * Used to access the Actor's ability to {@link BrowseTheWebWithWebdriverIO}
53
48
  * from within the {@link @serenity-js/core/lib/screenplay~Interaction} classes,
54
- * such as {@link Navigate}.
49
+ * such as {@link @serenity-js/web/lib/screenplay/interactions~Navigate}.
55
50
  *
56
51
  * @param {@serenity-js/core/lib/screenplay/actor~UsesAbilities} actor
57
- * @return {BrowseTheWeb}
52
+ * @return {BrowseTheWebWithWebdriverIO}
53
+ */
54
+ static as(actor: UsesAbilities): BrowseTheWebWithWebdriverIO;
55
+ /**
56
+ * @private
58
57
  */
59
- static as(actor: UsesAbilities): BrowseTheWeb;
58
+ private lastScriptExecutionSummary;
60
59
  /**
61
60
  * @param {@wdio/types~Browser} browser
62
61
  */
63
- constructor(browser: Browser<'async'>);
62
+ constructor(browser: wdio.Browser<'async'>);
63
+ browserCapabilities(): Promise<BrowserCapabilities>;
64
+ cookie(name: string): Promise<Cookie>;
65
+ setCookie(cookieData: CookieData): Promise<void>;
66
+ deleteAllCookies(): Promise<void>;
67
+ findByCss(selector: string): WebdriverIOPageElement;
68
+ /**
69
+ * @desc
70
+ * Retrieves a {@link @serenity-js/web/lib/screenplay/models~PageElement} which text includes `text`
71
+ * and which can be located using the CSS `selector`.
72
+ *
73
+ * Under the hood, this command uses https://webdriver.io/docs/selectors#element-with-certain-text
74
+ *
75
+ * This means that only some selectors are supported. For example:
76
+ * - 'h1'
77
+ * - 'h1.some-class'
78
+ * - '#someId'
79
+ * - 'h1[attribute-name="attribute-selector"]
80
+ *
81
+ * Notably, complex CSS selectors such as 'header h1' or 'header > h1' **WON'T WORK**.
82
+ *
83
+ * @param {string} selector
84
+ * @param {string} text
85
+ * @returns {@serenity-js/web/lib/screenplay/models~PageElement}
86
+ */
87
+ findByCssContainingText(selector: string, text: RegExp | string): WebdriverIOPageElement;
88
+ findById(selector: string): WebdriverIOPageElement;
89
+ findByTagName(selector: string): WebdriverIOPageElement;
90
+ findByXPath(selector: string): WebdriverIOPageElement;
91
+ findAllByCss(selector: string): WebdriverIOPageElements;
92
+ findAllByTagName(selector: string): WebdriverIOPageElements;
93
+ findAllByXPath(selector: string): WebdriverIOPageElements;
94
+ private find;
95
+ private findAll;
64
96
  /**
65
97
  * @desc
66
98
  * Navigate to a given destination, specified as an absolute URL
@@ -69,7 +101,29 @@ export declare class BrowseTheWeb implements Ability {
69
101
  * @param {string} destination
70
102
  * @returns {Promise<void>}
71
103
  */
72
- get(destination: string): Promise<void>;
104
+ navigateTo(destination: string): Promise<void>;
105
+ navigateBack(): Promise<void>;
106
+ navigateForward(): Promise<void>;
107
+ reloadPage(): Promise<void>;
108
+ /**
109
+ * @desc
110
+ * Returns a {@link Page} representing the currently active top-level browsing context.
111
+ *
112
+ * @returns {Promise<Page>}
113
+ */
114
+ currentPage(): Promise<Page>;
115
+ /**
116
+ * @desc
117
+ * Returns an array of {@link Page} objects representing all the available
118
+ * top-level browsing context, e.g. all the open browser tabs.
119
+ *
120
+ * @returns {Promise<Array<Page>>}
121
+ */
122
+ allPages(): Promise<Array<Page>>;
123
+ modalDialog(): Promise<ModalDialog>;
124
+ switchToFrame(targetOrIndex: PageElement | number | string): Promise<void>;
125
+ switchToParentFrame(): Promise<void>;
126
+ switchToDefaultContent(): Promise<void>;
73
127
  /**
74
128
  * @desc
75
129
  * Send a sequence of {@link Key} strokes to the active element.
@@ -143,7 +197,7 @@ export declare class BrowseTheWeb implements Ability {
143
197
  * Arrays and objects may also be used as script arguments as long as each item adheres
144
198
  * to the types previously mentioned.
145
199
  *
146
- * Unlike executing synchronous JavaScript with {@link BrowseTheWeb#executeScript},
200
+ * Unlike executing synchronous JavaScript with {@link BrowseTheWebWithWebdriverIO#executeScript},
147
201
  * scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
148
202
  *
149
203
  * This callback will always be injected into the executed function as the last argument,
@@ -185,10 +239,12 @@ export declare class BrowseTheWeb implements Ability {
185
239
  executeAsyncScript<Result, Parameters extends any[]>(script: string | ((...args: [...parameters: Parameters, callback: (result: Result) => void]) => void), ...args: Parameters): Promise<Result>;
186
240
  /**
187
241
  * @desc
188
- * Returns the last result of calling {@link BrowseTheWeb#executeAsyncScript}
189
- * or {@link BrowseTheWeb#executeScript}
242
+ * Returns the last result of calling {@link BrowseTheWebWithWebdriverIO#executeAsyncScript}
243
+ * or {@link BrowseTheWebWithWebdriverIO#executeScript}
190
244
  *
191
245
  * @returns {any}
192
246
  */
193
- getLastScriptExecutionResult<Result = any>(): Result;
247
+ lastScriptExecutionResult<Result = any>(): Result;
248
+ waitFor(duration: Duration): Promise<void>;
249
+ waitUntil(condition: () => boolean | Promise<boolean>, timeout: Duration): Promise<void>;
194
250
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BrowseTheWeb = void 0;
3
+ exports.BrowseTheWebWithWebdriverIO = void 0;
4
4
  const core_1 = require("@serenity-js/core");
5
- const input_1 = require("../../input");
5
+ const web_1 = require("@serenity-js/web");
6
+ const models_1 = require("../models");
6
7
  /**
7
8
  * @desc
8
9
  * An {@link @serenity-js/core/lib/screenplay~Ability} that enables the {@link @serenity-js/core/lib/screenplay/actor~Actor}
@@ -12,8 +13,6 @@ const input_1 = require("../../input");
12
13
  * This means that its interface can change without affecting the major version of Serenity/JS itself.
13
14
  * In particular, please don't rely on the `browser` field to remain `public` in future releases.
14
15
  *
15
- * @experimental
16
- *
17
16
  * @example <caption>Using the WebdriverIO browser</caption>
18
17
  * import { Actor } from '@serenity-js/core';
19
18
  * import { BrowseTheWeb, by, Navigate, Target } from '@serenity-js/webdriverio'
@@ -38,31 +37,107 @@ const input_1 = require("../../input");
38
37
  * @implements {@serenity-js/core/lib/screenplay~Ability}
39
38
  * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
40
39
  */
41
- class BrowseTheWeb {
40
+ class BrowseTheWebWithWebdriverIO extends web_1.BrowseTheWeb {
42
41
  /**
43
42
  * @param {@wdio/types~Browser} browser
44
43
  */
45
44
  constructor(browser) {
45
+ super();
46
46
  this.browser = browser;
47
+ if (!this.browser.$ || !this.browser.$$) {
48
+ throw new core_1.LogicError(`WebdriverIO browser object is not initalised yet, so can't be assigned to an actor. Are you trying to instantiate an actor outside of a test or a test hook?`);
49
+ }
47
50
  }
48
51
  /**
49
52
  * @param {@wdio/types~Browser} browserInstance
50
- * @returns {BrowseTheWeb}
53
+ * @returns {BrowseTheWebWithWebdriverIO}
51
54
  */
52
55
  static using(browserInstance) {
53
- return new BrowseTheWeb(browserInstance);
56
+ return new BrowseTheWebWithWebdriverIO(browserInstance);
54
57
  }
55
58
  /**
56
59
  * @desc
57
- * Used to access the Actor's ability to {@link BrowseTheWeb}
60
+ * Used to access the Actor's ability to {@link BrowseTheWebWithWebdriverIO}
58
61
  * from within the {@link @serenity-js/core/lib/screenplay~Interaction} classes,
59
- * such as {@link Navigate}.
62
+ * such as {@link @serenity-js/web/lib/screenplay/interactions~Navigate}.
60
63
  *
61
64
  * @param {@serenity-js/core/lib/screenplay/actor~UsesAbilities} actor
62
- * @return {BrowseTheWeb}
65
+ * @return {BrowseTheWebWithWebdriverIO}
63
66
  */
64
67
  static as(actor) {
65
- return actor.abilityTo(BrowseTheWeb);
68
+ return actor.abilityTo(BrowseTheWebWithWebdriverIO);
69
+ }
70
+ browserCapabilities() {
71
+ return Promise.resolve(this.browser.capabilities);
72
+ }
73
+ async cookie(name) {
74
+ return new models_1.WebdriverIOCookie(this.browser, name);
75
+ }
76
+ async setCookie(cookieData) {
77
+ return this.browser.setCookies({
78
+ name: cookieData.name,
79
+ value: cookieData.value,
80
+ path: cookieData.path,
81
+ domain: cookieData.domain,
82
+ secure: cookieData.secure,
83
+ httpOnly: cookieData.httpOnly,
84
+ expiry: cookieData.expiry
85
+ ? cookieData.expiry.toSeconds()
86
+ : undefined,
87
+ sameSite: cookieData.sameSite,
88
+ });
89
+ }
90
+ deleteAllCookies() {
91
+ return this.browser.deleteCookies();
92
+ }
93
+ findByCss(selector) {
94
+ return this.find(root => root.$(selector));
95
+ }
96
+ /**
97
+ * @desc
98
+ * Retrieves a {@link @serenity-js/web/lib/screenplay/models~PageElement} which text includes `text`
99
+ * and which can be located using the CSS `selector`.
100
+ *
101
+ * Under the hood, this command uses https://webdriver.io/docs/selectors#element-with-certain-text
102
+ *
103
+ * This means that only some selectors are supported. For example:
104
+ * - 'h1'
105
+ * - 'h1.some-class'
106
+ * - '#someId'
107
+ * - 'h1[attribute-name="attribute-selector"]
108
+ *
109
+ * Notably, complex CSS selectors such as 'header h1' or 'header > h1' **WON'T WORK**.
110
+ *
111
+ * @param {string} selector
112
+ * @param {string} text
113
+ * @returns {@serenity-js/web/lib/screenplay/models~PageElement}
114
+ */
115
+ findByCssContainingText(selector, text) {
116
+ return this.find(root => root.$(`${selector}*=${text}`));
117
+ }
118
+ findById(selector) {
119
+ return this.find(root => root.$(`#${selector}`));
120
+ }
121
+ findByTagName(selector) {
122
+ return this.find(root => root.$(`<${selector} />`));
123
+ }
124
+ findByXPath(selector) {
125
+ return this.find(root => root.$(selector));
126
+ }
127
+ findAllByCss(selector) {
128
+ return this.findAll(root => root.$$(selector));
129
+ }
130
+ findAllByTagName(selector) {
131
+ return this.findAll(root => root.$$(`<${selector} />`));
132
+ }
133
+ findAllByXPath(selector) {
134
+ return this.findAll(root => root.$$(selector));
135
+ }
136
+ find(locator) {
137
+ return new models_1.WebdriverIOPageElement(() => this.browser, locator);
138
+ }
139
+ findAll(locator) {
140
+ return new models_1.WebdriverIOPageElements(() => this.browser, locator);
66
141
  }
67
142
  /**
68
143
  * @desc
@@ -72,9 +147,54 @@ class BrowseTheWeb {
72
147
  * @param {string} destination
73
148
  * @returns {Promise<void>}
74
149
  */
75
- get(destination) {
150
+ navigateTo(destination) {
76
151
  return this.browser.url(destination); // todo: check if this returns a string or is mistyped
77
152
  }
153
+ navigateBack() {
154
+ return this.browser.back();
155
+ }
156
+ navigateForward() {
157
+ return this.browser.forward();
158
+ }
159
+ reloadPage() {
160
+ return this.browser.refresh();
161
+ }
162
+ /**
163
+ * @desc
164
+ * Returns a {@link Page} representing the currently active top-level browsing context.
165
+ *
166
+ * @returns {Promise<Page>}
167
+ */
168
+ async currentPage() {
169
+ const windowHandle = await this.browser.getWindowHandle();
170
+ return new models_1.WebdriverIOPage(this.browser, windowHandle);
171
+ }
172
+ /**
173
+ * @desc
174
+ * Returns an array of {@link Page} objects representing all the available
175
+ * top-level browsing context, e.g. all the open browser tabs.
176
+ *
177
+ * @returns {Promise<Array<Page>>}
178
+ */
179
+ async allPages() {
180
+ const windowHandles = await this.browser.getWindowHandles();
181
+ return windowHandles.map(windowHandle => new models_1.WebdriverIOPage(this.browser, windowHandle));
182
+ }
183
+ async modalDialog() {
184
+ return new models_1.WebdriverIOModalDialog(this.browser);
185
+ }
186
+ // todo: remove
187
+ switchToFrame(targetOrIndex) {
188
+ throw new Error('Not implemented, yet');
189
+ }
190
+ // todo: remove
191
+ switchToParentFrame() {
192
+ throw new Error('Not implemented, yet');
193
+ }
194
+ // todo: remove
195
+ switchToDefaultContent() {
196
+ throw new Error('Not implemented, yet');
197
+ }
78
198
  /**
79
199
  * @desc
80
200
  * Send a sequence of {@link Key} strokes to the active element.
@@ -88,10 +208,10 @@ class BrowseTheWeb {
88
208
  */
89
209
  sendKeys(keys) {
90
210
  const keySequence = keys.map(key => {
91
- if (!input_1.Key.isKey(key)) {
211
+ if (!web_1.Key.isKey(key)) {
92
212
  return key;
93
213
  }
94
- if (browser.isDevTools) {
214
+ if (this.browser.isDevTools) {
95
215
  return key.devtoolsName;
96
216
  }
97
217
  return key.utf16codePoint;
@@ -148,8 +268,9 @@ class BrowseTheWeb {
148
268
  *
149
269
  * @see {@link BrowseTheWeb#getLastScriptExecutionResult}
150
270
  */
151
- executeScript(script, ...args) {
152
- return this.browser.execute(script, ...args)
271
+ async executeScript(script, ...args) {
272
+ const nativeArguments = await Promise.all(args.map(arg => arg instanceof models_1.WebdriverIOPageElement ? arg.nativeElement() : arg));
273
+ return this.browser.execute(script, ...nativeArguments)
153
274
  .then(result => {
154
275
  this.lastScriptExecutionSummary = new LastScriptExecutionSummary(result);
155
276
  return result;
@@ -167,7 +288,7 @@ class BrowseTheWeb {
167
288
  * Arrays and objects may also be used as script arguments as long as each item adheres
168
289
  * to the types previously mentioned.
169
290
  *
170
- * Unlike executing synchronous JavaScript with {@link BrowseTheWeb#executeScript},
291
+ * Unlike executing synchronous JavaScript with {@link BrowseTheWebWithWebdriverIO#executeScript},
171
292
  * scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
172
293
  *
173
294
  * This callback will always be injected into the executed function as the last argument,
@@ -206,8 +327,9 @@ class BrowseTheWeb {
206
327
  *
207
328
  * @see {@link BrowseTheWeb#getLastScriptExecutionResult}
208
329
  */
209
- executeAsyncScript(script, ...args) {
210
- return this.browser.executeAsync(script, ...args)
330
+ async executeAsyncScript(script, ...args) {
331
+ const nativeArguments = await Promise.all(args.map(arg => arg instanceof models_1.WebdriverIOPageElement ? arg.nativeElement() : arg));
332
+ return this.browser.executeAsync(script, ...nativeArguments)
211
333
  .then(result => {
212
334
  this.lastScriptExecutionSummary = new LastScriptExecutionSummary(result);
213
335
  return result;
@@ -215,19 +337,32 @@ class BrowseTheWeb {
215
337
  }
216
338
  /**
217
339
  * @desc
218
- * Returns the last result of calling {@link BrowseTheWeb#executeAsyncScript}
219
- * or {@link BrowseTheWeb#executeScript}
340
+ * Returns the last result of calling {@link BrowseTheWebWithWebdriverIO#executeAsyncScript}
341
+ * or {@link BrowseTheWebWithWebdriverIO#executeScript}
220
342
  *
221
343
  * @returns {any}
222
344
  */
223
- getLastScriptExecutionResult() {
345
+ lastScriptExecutionResult() {
224
346
  if (!this.lastScriptExecutionSummary) {
225
347
  throw new core_1.LogicError(`Make sure to execute a script before checking on the result`);
226
348
  }
227
- return this.lastScriptExecutionSummary.result;
349
+ // Selenium returns `null` when the script it executed returns `undefined`
350
+ // so we're mapping the result back.
351
+ return this.lastScriptExecutionSummary.result !== null
352
+ ? this.lastScriptExecutionSummary.result
353
+ : undefined;
354
+ }
355
+ waitFor(duration) {
356
+ return this.browser.pause(duration.inMilliseconds());
357
+ }
358
+ waitUntil(condition, timeout) {
359
+ return this.browser.waitUntil(condition, {
360
+ timeout: timeout.inMilliseconds(),
361
+ timeoutMsg: `Wait timed out after ${timeout}`,
362
+ });
228
363
  }
229
364
  }
230
- exports.BrowseTheWeb = BrowseTheWeb;
365
+ exports.BrowseTheWebWithWebdriverIO = BrowseTheWebWithWebdriverIO;
231
366
  /**
232
367
  * @package
233
368
  */
@@ -236,4 +371,4 @@ class LastScriptExecutionSummary {
236
371
  this.result = result;
237
372
  }
238
373
  }
239
- //# sourceMappingURL=BrowseTheWeb.js.map
374
+ //# sourceMappingURL=BrowseTheWebWithWebdriverIO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowseTheWebWithWebdriverIO.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithWebdriverIO.ts"],"names":[],"mappings":";;;AAAA,4CAAwE;AACxE,0CAA8H;AAG9H,sCAAsK;AAEtK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAa,2BAA4B,SAAQ,kBAAY;IA4BzD;;OAEG;IACH,YAA4B,OAA8B;QACtD,KAAK,EAAE,CAAC;QADgB,YAAO,GAAP,OAAO,CAAuB;QAGtD,IAAI,CAAE,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;YACvC,MAAM,IAAI,iBAAU,CAAC,8JAA8J,CAAC,CAAA;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G;AACH,MAAM,0BAA0B;IAC5B,YAA4B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;CACjD"}
@@ -1 +1 @@
1
- export * from './BrowseTheWeb';
1
+ export * from './BrowseTheWebWithWebdriverIO';
@@ -10,5 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./BrowseTheWeb"), exports);
13
+ __exportStar(require("./BrowseTheWebWithWebdriverIO"), exports);
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA8C"}
@@ -1,3 +1,2 @@
1
1
  export * from './abilities';
2
- export * from './interactions';
3
- export * from './questions';
2
+ export * from './models';
@@ -11,6 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./abilities"), exports);
14
- __exportStar(require("./interactions"), exports);
15
- __exportStar(require("./questions"), exports);
14
+ __exportStar(require("./models"), exports);
16
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,iDAA+B;AAC/B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB"}
@@ -0,0 +1,8 @@
1
+ import { Cookie, CookieData } from '@serenity-js/web';
2
+ import * as wdio from 'webdriverio';
3
+ export declare class WebdriverIOCookie extends Cookie {
4
+ private readonly browser;
5
+ constructor(browser: wdio.Browser<'async'>, cookieName: string);
6
+ delete(): Promise<void>;
7
+ protected read(): Promise<CookieData>;
8
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebdriverIOCookie = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const web_1 = require("@serenity-js/web");
6
+ const tiny_types_1 = require("tiny-types");
7
+ class WebdriverIOCookie extends web_1.Cookie {
8
+ constructor(browser, cookieName) {
9
+ super(cookieName);
10
+ this.browser = browser;
11
+ (0, tiny_types_1.ensure)('browser', browser, (0, tiny_types_1.isDefined)());
12
+ }
13
+ async delete() {
14
+ return this.browser.deleteCookies(this.cookieName);
15
+ }
16
+ async read() {
17
+ const [cookie] = await this.browser.getCookies(this.cookieName);
18
+ if (!cookie) {
19
+ throw new web_1.CookieMissingError(`Cookie '${this.cookieName}' not set`);
20
+ }
21
+ // There _might_ be a bug in WDIO where the expiry date is set on "expires" rather than the "expiry" key
22
+ // and possibly another one around deserialising the timestamp, since WDIO seems to add several hundred milliseconds
23
+ // to the original expiry date
24
+ const expiry = cookie.expiry || cookie.expires;
25
+ return {
26
+ name: cookie.name,
27
+ value: cookie.value,
28
+ domain: cookie.domain,
29
+ path: cookie.path,
30
+ expiry: expiry !== undefined
31
+ ? core_1.Timestamp.fromTimestampInSeconds(Math.round(expiry))
32
+ : undefined,
33
+ httpOnly: cookie.httpOnly,
34
+ secure: cookie.secure,
35
+ };
36
+ }
37
+ }
38
+ exports.WebdriverIOCookie = WebdriverIOCookie;
39
+ //# sourceMappingURL=WebdriverIOCookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebdriverIOCookie.js","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIOCookie.ts"],"names":[],"mappings":";;;AAAA,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Browser } from 'webdriverio';
3
+ export declare class WebdriverIOModalDialog extends ModalDialog {
4
+ private readonly browser;
5
+ constructor(browser: Browser<'async'>);
6
+ accept(): Promise<void>;
7
+ dismiss(): Promise<void>;
8
+ text(): Promise<string>;
9
+ enterValue(value: string | number | (string | number)[]): Promise<void>;
10
+ isPresent(): Promise<boolean>;
11
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebdriverIOModalDialog = void 0;
4
+ const web_1 = require("@serenity-js/web");
5
+ class WebdriverIOModalDialog extends web_1.ModalDialog {
6
+ constructor(browser) {
7
+ super();
8
+ this.browser = browser;
9
+ }
10
+ accept() {
11
+ return this.browser.acceptAlert();
12
+ }
13
+ dismiss() {
14
+ return this.browser.dismissAlert();
15
+ }
16
+ text() {
17
+ return this.browser.getAlertText();
18
+ }
19
+ async enterValue(value) {
20
+ const text = [].concat(value).join('');
21
+ await this.browser.sendAlertText(text);
22
+ // Puppeteer auto-accepts the dialog upon sendAlertText
23
+ // other implementations require the dialog to be closed
24
+ if (!this.browser.isDevTools) {
25
+ await this.browser.acceptAlert();
26
+ }
27
+ }
28
+ isPresent() {
29
+ return this.browser.getAlertText()
30
+ .then(() => true, error => {
31
+ if (error && (error.name === 'no such alert'
32
+ || error.message.startsWith('no such alert'))) {
33
+ return false;
34
+ }
35
+ throw error;
36
+ });
37
+ }
38
+ }
39
+ exports.WebdriverIOModalDialog = WebdriverIOModalDialog;
40
+ //# sourceMappingURL=WebdriverIOModalDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebdriverIOModalDialog.js","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIOModalDialog.ts"],"names":[],"mappings":";;;AAAA,0CAA+C;AAG/C,MAAa,sBAAuB,SAAQ,iBAAW;IACnD,YAA6B,OAAyB;QAClD,KAAK,EAAE,CAAC;QADiB,YAAO,GAAP,OAAO,CAAkB;IAEtD,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IACD,IAAI;QACA,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAA4C;QACzD,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEvC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEvC,uDAAuD;QACvD,wDAAwD;QACxD,IAAI,CAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;SACpC;IACL,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;aAC7B,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;YACtB,IAAI,KAAK,IAAI,CACT,KAAK,CAAC,IAAI,KAAK,eAAe;mBAC3B,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAC/C,EAAE;gBACC,OAAO,KAAK,CAAC;aAChB;YAED,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AAzCD,wDAyCC"}
@@ -0,0 +1,2 @@
1
+ import * as wdio from 'webdriverio';
2
+ export declare type WebdriverIONativeElementRoot = Pick<wdio.Browser<'async'>, '$' | '$$' | 'react$' | 'react$$'>;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=EnterBuilder.js.map
3
+ //# sourceMappingURL=WebdriverIONativeElementRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebdriverIONativeElementRoot.js","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIONativeElementRoot.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import { Page } from '@serenity-js/web';
3
+ import { URL } from 'url';
4
+ import * as wdio from 'webdriverio';
5
+ export declare class WebdriverIOPage extends Page {
6
+ private readonly browser;
7
+ constructor(browser: wdio.Browser<'async'>, handle: string);
8
+ title(): Promise<string>;
9
+ name(): Promise<string>;
10
+ url(): Promise<URL>;
11
+ viewportSize(): Promise<{
12
+ width: number;
13
+ height: number;
14
+ }>;
15
+ setViewportSize(size: {
16
+ width: number;
17
+ height: number;
18
+ }): Promise<void>;
19
+ close(): Promise<void>;
20
+ closeOthers(): Promise<void>;
21
+ isPresent(): Promise<boolean>;
22
+ switchTo(): Promise<void>;
23
+ private switchToAndPerform;
24
+ }