@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.
- package/CHANGELOG.md +70 -0
- package/lib/adapter/WebdriverIOFrameworkAdapter.js +1 -1
- package/lib/adapter/WebdriverIOFrameworkAdapter.js.map +1 -1
- package/lib/adapter/WebdriverIONotifier.d.ts +35 -1
- package/lib/adapter/WebdriverIONotifier.js +174 -13
- package/lib/adapter/WebdriverIONotifier.js.map +1 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/{BrowseTheWeb.d.ts → BrowseTheWebWithWebdriverIO.d.ts} +79 -23
- package/lib/screenplay/abilities/{BrowseTheWeb.js → BrowseTheWebWithWebdriverIO.js} +160 -25
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -2
- package/lib/screenplay/index.js +1 -2
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOCookie.d.ts +8 -0
- package/lib/screenplay/models/WebdriverIOCookie.js +39 -0
- package/lib/screenplay/models/WebdriverIOCookie.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.d.ts +11 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js +40 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.js.map +1 -0
- package/lib/screenplay/models/WebdriverIONativeElementRoot.d.ts +2 -0
- package/lib/screenplay/{interactions/EnterBuilder.js → models/WebdriverIONativeElementRoot.js} +1 -1
- package/lib/screenplay/models/WebdriverIONativeElementRoot.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPage.d.ts +24 -0
- package/lib/screenplay/models/WebdriverIOPage.js +98 -0
- package/lib/screenplay/models/WebdriverIOPage.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElement.d.ts +22 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js +75 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElements.d.ts +15 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js +65 -0
- package/lib/screenplay/models/WebdriverIOPageElements.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +6 -0
- package/lib/{input → screenplay/models}/index.js +6 -1
- package/lib/screenplay/models/index.js.map +1 -0
- package/package.json +18 -28
- package/src/adapter/WebdriverIOFrameworkAdapter.ts +2 -0
- package/src/adapter/WebdriverIONotifier.ts +225 -23
- package/src/index.ts +0 -3
- package/src/screenplay/abilities/{BrowseTheWeb.ts → BrowseTheWebWithWebdriverIO.ts} +200 -31
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +1 -2
- package/src/screenplay/models/WebdriverIOCookie.ts +44 -0
- package/src/screenplay/models/WebdriverIOModalDialog.ts +45 -0
- package/src/screenplay/models/WebdriverIONativeElementRoot.ts +3 -0
- package/src/screenplay/models/WebdriverIOPage.ts +120 -0
- package/src/screenplay/models/WebdriverIOPageElement.ts +92 -0
- package/src/screenplay/models/WebdriverIOPageElements.ts +91 -0
- package/src/screenplay/models/index.ts +6 -0
- package/lib/expectations/ElementExpectation.d.ts +0 -11
- package/lib/expectations/ElementExpectation.js +0 -27
- package/lib/expectations/ElementExpectation.js.map +0 -1
- package/lib/expectations/index.d.ts +0 -6
- package/lib/expectations/index.js +0 -19
- package/lib/expectations/index.js.map +0 -1
- package/lib/expectations/isActive.d.ts +0 -15
- package/lib/expectations/isActive.js +0 -21
- package/lib/expectations/isActive.js.map +0 -1
- package/lib/expectations/isClickable.d.ts +0 -20
- package/lib/expectations/isClickable.js +0 -26
- package/lib/expectations/isClickable.js.map +0 -1
- package/lib/expectations/isEnabled.d.ts +0 -14
- package/lib/expectations/isEnabled.js +0 -20
- package/lib/expectations/isEnabled.js.map +0 -1
- package/lib/expectations/isPresent.d.ts +0 -15
- package/lib/expectations/isPresent.js +0 -21
- package/lib/expectations/isPresent.js.map +0 -1
- package/lib/expectations/isSelected.d.ts +0 -14
- package/lib/expectations/isSelected.js +0 -20
- package/lib/expectations/isSelected.js.map +0 -1
- package/lib/expectations/isVisible.d.ts +0 -14
- package/lib/expectations/isVisible.js +0 -20
- package/lib/expectations/isVisible.js.map +0 -1
- package/lib/input/Key.d.ts +0 -73
- package/lib/input/Key.js +0 -84
- package/lib/input/Key.js.map +0 -1
- package/lib/input/index.d.ts +0 -1
- package/lib/input/index.js.map +0 -1
- package/lib/screenplay/abilities/BrowseTheWeb.js.map +0 -1
- package/lib/screenplay/interactions/Clear.d.ts +0 -79
- package/lib/screenplay/interactions/Clear.js +0 -97
- package/lib/screenplay/interactions/Clear.js.map +0 -1
- package/lib/screenplay/interactions/Click.d.ts +0 -73
- package/lib/screenplay/interactions/Click.js +0 -84
- package/lib/screenplay/interactions/Click.js.map +0 -1
- package/lib/screenplay/interactions/DoubleClick.d.ts +0 -90
- package/lib/screenplay/interactions/DoubleClick.js +0 -101
- package/lib/screenplay/interactions/DoubleClick.js.map +0 -1
- package/lib/screenplay/interactions/Enter.d.ts +0 -73
- package/lib/screenplay/interactions/Enter.js +0 -87
- package/lib/screenplay/interactions/Enter.js.map +0 -1
- package/lib/screenplay/interactions/EnterBuilder.d.ts +0 -25
- package/lib/screenplay/interactions/EnterBuilder.js.map +0 -1
- package/lib/screenplay/interactions/ExecuteScript.d.ts +0 -206
- package/lib/screenplay/interactions/ExecuteScript.js +0 -311
- package/lib/screenplay/interactions/ExecuteScript.js.map +0 -1
- package/lib/screenplay/interactions/Hover.d.ts +0 -78
- package/lib/screenplay/interactions/Hover.js +0 -89
- package/lib/screenplay/interactions/Hover.js.map +0 -1
- package/lib/screenplay/interactions/Navigate.d.ts +0 -141
- package/lib/screenplay/interactions/Navigate.js +0 -197
- package/lib/screenplay/interactions/Navigate.js.map +0 -1
- package/lib/screenplay/interactions/Press.d.ts +0 -84
- package/lib/screenplay/interactions/Press.js +0 -152
- package/lib/screenplay/interactions/Press.js.map +0 -1
- package/lib/screenplay/interactions/PressBuilder.d.ts +0 -26
- package/lib/screenplay/interactions/PressBuilder.js +0 -3
- package/lib/screenplay/interactions/PressBuilder.js.map +0 -1
- package/lib/screenplay/interactions/RightClick.d.ts +0 -89
- package/lib/screenplay/interactions/RightClick.js +0 -100
- package/lib/screenplay/interactions/RightClick.js.map +0 -1
- package/lib/screenplay/interactions/Scroll.d.ts +0 -75
- package/lib/screenplay/interactions/Scroll.js +0 -86
- package/lib/screenplay/interactions/Scroll.js.map +0 -1
- package/lib/screenplay/interactions/Wait.d.ts +0 -143
- package/lib/screenplay/interactions/Wait.js +0 -247
- package/lib/screenplay/interactions/Wait.js.map +0 -1
- package/lib/screenplay/interactions/WaitBuilder.d.ts +0 -32
- package/lib/screenplay/interactions/WaitBuilder.js +0 -3
- package/lib/screenplay/interactions/WaitBuilder.js.map +0 -1
- package/lib/screenplay/interactions/WebElementInteraction.d.ts +0 -37
- package/lib/screenplay/interactions/WebElementInteraction.js +0 -52
- package/lib/screenplay/interactions/WebElementInteraction.js.map +0 -1
- package/lib/screenplay/interactions/index.d.ts +0 -13
- package/lib/screenplay/interactions/index.js +0 -26
- package/lib/screenplay/interactions/index.js.map +0 -1
- package/lib/screenplay/questions/Attribute.d.ts +0 -82
- package/lib/screenplay/questions/Attribute.js +0 -102
- package/lib/screenplay/questions/Attribute.js.map +0 -1
- package/lib/screenplay/questions/CSSClasses.d.ts +0 -92
- package/lib/screenplay/questions/CSSClasses.js +0 -112
- package/lib/screenplay/questions/CSSClasses.js.map +0 -1
- package/lib/screenplay/questions/LastScriptExecution.d.ts +0 -14
- package/lib/screenplay/questions/LastScriptExecution.js +0 -22
- package/lib/screenplay/questions/LastScriptExecution.js.map +0 -1
- package/lib/screenplay/questions/NestedTargetBuilder.d.ts +0 -27
- package/lib/screenplay/questions/NestedTargetBuilder.js +0 -3
- package/lib/screenplay/questions/NestedTargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/TargetBuilder.d.ts +0 -25
- package/lib/screenplay/questions/TargetBuilder.js +0 -3
- package/lib/screenplay/questions/TargetBuilder.js.map +0 -1
- package/lib/screenplay/questions/Text.d.ts +0 -95
- package/lib/screenplay/questions/Text.js +0 -130
- package/lib/screenplay/questions/Text.js.map +0 -1
- package/lib/screenplay/questions/Value.d.ts +0 -63
- package/lib/screenplay/questions/Value.js +0 -78
- package/lib/screenplay/questions/Value.js.map +0 -1
- package/lib/screenplay/questions/Website.d.ts +0 -21
- package/lib/screenplay/questions/Website.js +0 -31
- package/lib/screenplay/questions/Website.js.map +0 -1
- package/lib/screenplay/questions/index.d.ts +0 -10
- package/lib/screenplay/questions/index.js +0 -23
- package/lib/screenplay/questions/index.js.map +0 -1
- package/lib/screenplay/questions/lists.d.ts +0 -86
- package/lib/screenplay/questions/lists.js +0 -137
- package/lib/screenplay/questions/lists.js.map +0 -1
- package/lib/screenplay/questions/locators.d.ts +0 -196
- package/lib/screenplay/questions/locators.js +0 -219
- package/lib/screenplay/questions/locators.js.map +0 -1
- package/lib/screenplay/questions/targets.d.ts +0 -254
- package/lib/screenplay/questions/targets.js +0 -334
- package/lib/screenplay/questions/targets.js.map +0 -1
- package/lib/stage/crew/index.d.ts +0 -1
- package/lib/stage/crew/index.js +0 -14
- package/lib/stage/crew/index.js.map +0 -1
- package/lib/stage/crew/photographer/Photographer.d.ts +0 -83
- package/lib/stage/crew/photographer/Photographer.js +0 -102
- package/lib/stage/crew/photographer/Photographer.js.map +0 -1
- package/lib/stage/crew/photographer/index.d.ts +0 -2
- package/lib/stage/crew/photographer/index.js +0 -15
- package/lib/stage/crew/photographer/index.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.d.ts +0 -28
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js +0 -65
- package/lib/stage/crew/photographer/strategies/PhotoTakingStrategy.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.d.ts +0 -18
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js +0 -30
- package/lib/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.d.ts +0 -17
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfFailures.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.d.ts +0 -19
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js +0 -28
- package/lib/stage/crew/photographer/strategies/TakePhotosOfInteractions.js.map +0 -1
- package/lib/stage/crew/photographer/strategies/index.d.ts +0 -4
- package/lib/stage/crew/photographer/strategies/index.js +0 -17
- package/lib/stage/crew/photographer/strategies/index.js.map +0 -1
- package/lib/stage/index.d.ts +0 -1
- package/lib/stage/index.js +0 -14
- package/lib/stage/index.js.map +0 -1
- package/src/expectations/ElementExpectation.ts +0 -31
- package/src/expectations/index.ts +0 -6
- package/src/expectations/isActive.ts +0 -21
- package/src/expectations/isClickable.ts +0 -26
- package/src/expectations/isEnabled.ts +0 -19
- package/src/expectations/isPresent.ts +0 -20
- package/src/expectations/isSelected.ts +0 -19
- package/src/expectations/isVisible.ts +0 -19
- package/src/input/Key.ts +0 -83
- package/src/input/index.ts +0 -1
- package/src/screenplay/interactions/Clear.ts +0 -102
- package/src/screenplay/interactions/Click.ts +0 -85
- package/src/screenplay/interactions/DoubleClick.ts +0 -102
- package/src/screenplay/interactions/Enter.ts +0 -93
- package/src/screenplay/interactions/EnterBuilder.ts +0 -27
- package/src/screenplay/interactions/ExecuteScript.ts +0 -344
- package/src/screenplay/interactions/Hover.ts +0 -90
- package/src/screenplay/interactions/Navigate.ts +0 -208
- package/src/screenplay/interactions/Press.ts +0 -172
- package/src/screenplay/interactions/PressBuilder.ts +0 -28
- package/src/screenplay/interactions/RightClick.ts +0 -100
- package/src/screenplay/interactions/Scroll.ts +0 -87
- package/src/screenplay/interactions/Wait.ts +0 -267
- package/src/screenplay/interactions/WaitBuilder.ts +0 -34
- package/src/screenplay/interactions/WebElementInteraction.ts +0 -56
- package/src/screenplay/interactions/index.ts +0 -13
- package/src/screenplay/questions/Attribute.ts +0 -112
- package/src/screenplay/questions/CSSClasses.ts +0 -116
- package/src/screenplay/questions/LastScriptExecution.ts +0 -21
- package/src/screenplay/questions/NestedTargetBuilder.ts +0 -30
- package/src/screenplay/questions/TargetBuilder.ts +0 -27
- package/src/screenplay/questions/Text.ts +0 -140
- package/src/screenplay/questions/Value.ts +0 -82
- package/src/screenplay/questions/Website.ts +0 -34
- package/src/screenplay/questions/index.ts +0 -10
- package/src/screenplay/questions/lists.ts +0 -161
- package/src/screenplay/questions/locators.ts +0 -254
- package/src/screenplay/questions/targets.ts +0 -401
- package/src/stage/crew/index.ts +0 -1
- package/src/stage/crew/photographer/Photographer.ts +0 -108
- package/src/stage/crew/photographer/index.ts +0 -2
- package/src/stage/crew/photographer/strategies/PhotoTakingStrategy.ts +0 -103
- package/src/stage/crew/photographer/strategies/TakePhotosBeforeAndAfterInteractions.ts +0 -28
- package/src/stage/crew/photographer/strategies/TakePhotosOfFailures.ts +0 -26
- package/src/stage/crew/photographer/strategies/TakePhotosOfInteractions.ts +0 -26
- package/src/stage/crew/photographer/strategies/index.ts +0 -4
- package/src/stage/index.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
|
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 {
|
|
42
|
+
* @returns {BrowseTheWebWithWebdriverIO}
|
|
48
43
|
*/
|
|
49
|
-
static using(browserInstance: Browser<'async'>):
|
|
44
|
+
static using(browserInstance: wdio.Browser<'async'>): BrowseTheWebWithWebdriverIO;
|
|
50
45
|
/**
|
|
51
46
|
* @desc
|
|
52
|
-
* Used to access the Actor's ability to {@link
|
|
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 {
|
|
52
|
+
* @return {BrowseTheWebWithWebdriverIO}
|
|
53
|
+
*/
|
|
54
|
+
static as(actor: UsesAbilities): BrowseTheWebWithWebdriverIO;
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
58
57
|
*/
|
|
59
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
189
|
-
* or {@link
|
|
242
|
+
* Returns the last result of calling {@link BrowseTheWebWithWebdriverIO#executeAsyncScript}
|
|
243
|
+
* or {@link BrowseTheWebWithWebdriverIO#executeScript}
|
|
190
244
|
*
|
|
191
245
|
* @returns {any}
|
|
192
246
|
*/
|
|
193
|
-
|
|
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.
|
|
3
|
+
exports.BrowseTheWebWithWebdriverIO = void 0;
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
|
-
const
|
|
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 {
|
|
53
|
+
* @returns {BrowseTheWebWithWebdriverIO}
|
|
51
54
|
*/
|
|
52
55
|
static using(browserInstance) {
|
|
53
|
-
return new
|
|
56
|
+
return new BrowseTheWebWithWebdriverIO(browserInstance);
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
59
|
* @desc
|
|
57
|
-
* Used to access the Actor's ability to {@link
|
|
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 {
|
|
65
|
+
* @return {BrowseTheWebWithWebdriverIO}
|
|
63
66
|
*/
|
|
64
67
|
static as(actor) {
|
|
65
|
-
return actor.abilityTo(
|
|
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
|
-
|
|
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 (!
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
219
|
-
* or {@link
|
|
340
|
+
* Returns the last result of calling {@link BrowseTheWebWithWebdriverIO#executeAsyncScript}
|
|
341
|
+
* or {@link BrowseTheWebWithWebdriverIO#executeScript}
|
|
220
342
|
*
|
|
221
343
|
* @returns {any}
|
|
222
344
|
*/
|
|
223
|
-
|
|
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
|
-
|
|
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.
|
|
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=
|
|
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;SACvL;IACL,CAAC;IAnCD;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,eAAsC;QAC/C,OAAO,IAAI,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,CAAC,KAAoB;QAC1B,OAAO,KAAK,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;IACxD,CAAC;IAkBD,mBAAmB;QACf,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAmC,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACrB,OAAO,IAAI,0BAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,UAAsB;QAClC,OAAO,I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,CAAC;IACX,CAAC;IAED;;;;;;OAMG;IACH,yBAAyB;QACrB,IAAI,CAAE,IAAI,CAAC,0BAA0B,EAAE;YACnC,MAAM,IAAI,iBAAU,CAAC,6DAA6D,CAAC,CAAC;SACvF;QAED,0EAA0E;QAC1E,oCAAoC;QACpC,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,KAAK,IAAI;YAClD,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,MAAgB;YAClD,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,QAAkB;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAkB,CAAC;IAC1E,CAAC;IAED,SAAS,CAAC,SAA2C,EAAE,OAAiB;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE;YACrC,OAAO,EAAK,OAAO,CAAC,cAAc,EAAE;YACpC,UAAU,EAAE,wBAAyB,OAAQ,EAAE;SAClD,CAAkB,CAAC;IACxB,CAAC;CACJ;AAlYD,kEAkYC;AAED;;GAEG;AACH,MAAM,0BAA0B;IAC5B,YAA4B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;CACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
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("./
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA8C"}
|
package/lib/screenplay/index.js
CHANGED
|
@@ -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("./
|
|
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,
|
|
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,4CAA8C;AAC9C,0CAA0E;AAC1E,2CAA+C;AAG/C,MAAa,iBAAkB,SAAQ,YAAM;IAEzC,YACqB,OAA8B,EAC/C,UAAkB;QAElB,KAAK,CAAC,UAAU,CAAC,CAAC;QAHD,YAAO,GAAP,OAAO,CAAuB;QAI/C,IAAA,mBAAM,EAAC,SAAS,EAAE,OAAO,EAAE,IAAA,sBAAS,GAAE,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAkB,CAAC;IACxE,CAAC;IAES,KAAK,CAAC,IAAI;QAChB,MAAM,CAAE,MAAM,CAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElE,IAAI,CAAE,MAAM,EAAE;YACV,MAAM,IAAI,wBAAkB,CAAC,WAAY,IAAI,CAAC,UAAW,WAAW,CAAC,CAAC;SACzE;QAED,wGAAwG;QACxG,oHAAoH;QACpH,8BAA8B;QAC9B,MAAM,MAAM,GAAuB,MAAM,CAAC,MAAM,IAAK,MAAc,CAAC,OAAO,CAAC;QAE5E,OAAO;YACH,IAAI,EAAQ,MAAM,CAAC,IAAI;YACvB,KAAK,EAAO,MAAM,CAAC,KAAK;YACxB,MAAM,EAAM,MAAM,CAAC,MAAM;YACzB,IAAI,EAAQ,MAAM,CAAC,IAAI;YACvB,MAAM,EAAM,MAAM,KAAK,SAAS;gBAC5B,CAAC,CAAC,gBAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACtD,CAAC,CAAC,SAAS;YACf,QAAQ,EAAI,MAAM,CAAC,QAAQ;YAC3B,MAAM,EAAM,MAAM,CAAC,MAAM;SAC5B,CAAA;IACL,CAAC;CACJ;AAtCD,8CAsCC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModalDialog } from '@serenity-js/web';
|
|
2
|
+
import { 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 @@
|
|
|
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
|
+
}
|