@serenity-js/webdriverio 3.0.0-rc.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +239 -124
- package/README.md +66 -45
- package/lib/adapter/TestRunnerLoader.d.ts +3 -4
- package/lib/adapter/TestRunnerLoader.d.ts.map +1 -0
- package/lib/adapter/TestRunnerLoader.js +1 -4
- package/lib/adapter/TestRunnerLoader.js.map +1 -1
- package/lib/adapter/WebdriverIOConfig.d.ts +115 -109
- package/lib/adapter/WebdriverIOConfig.d.ts.map +1 -0
- package/lib/adapter/WebdriverIOFrameworkAdapter.d.ts +1 -3
- package/lib/adapter/WebdriverIOFrameworkAdapter.d.ts.map +1 -0
- package/lib/adapter/WebdriverIOFrameworkAdapter.js +14 -8
- package/lib/adapter/WebdriverIOFrameworkAdapter.js.map +1 -1
- package/lib/adapter/WebdriverIOFrameworkAdapterFactory.d.ts +2 -1
- package/lib/adapter/WebdriverIOFrameworkAdapterFactory.d.ts.map +1 -0
- package/lib/adapter/WebdriverIOFrameworkAdapterFactory.js +1 -1
- package/lib/adapter/WebdriverIONotifier.d.ts +1 -0
- package/lib/adapter/WebdriverIONotifier.d.ts.map +1 -0
- package/lib/adapter/WebdriverIONotifier.js +5 -5
- package/lib/adapter/WebdriverIONotifier.js.map +1 -1
- package/lib/adapter/index.d.ts +1 -1
- package/lib/adapter/index.d.ts.map +1 -0
- package/lib/adapter/index.js +5 -2
- package/lib/adapter/index.js.map +1 -1
- package/lib/adapter/reporter/BrowserCapabilitiesReporter.d.ts +1 -0
- package/lib/adapter/reporter/BrowserCapabilitiesReporter.d.ts.map +1 -0
- package/lib/adapter/reporter/BrowserCapabilitiesReporter.js +4 -1
- package/lib/adapter/reporter/BrowserCapabilitiesReporter.js.map +1 -1
- package/lib/adapter/reporter/InitialisesReporters.d.ts +1 -0
- package/lib/adapter/reporter/InitialisesReporters.d.ts.map +1 -0
- package/lib/adapter/reporter/OutputStreamBuffer.d.ts +2 -1
- package/lib/adapter/reporter/OutputStreamBuffer.d.ts.map +1 -0
- package/lib/adapter/reporter/OutputStreamBufferPrinter.d.ts +2 -1
- package/lib/adapter/reporter/OutputStreamBufferPrinter.d.ts.map +1 -0
- package/lib/adapter/reporter/OutputStreamBufferPrinter.js.map +1 -1
- package/lib/adapter/reporter/ProvidesWriteStream.d.ts +2 -1
- package/lib/adapter/reporter/ProvidesWriteStream.d.ts.map +1 -0
- package/lib/adapter/reporter/TagPrinter.d.ts +1 -0
- package/lib/adapter/reporter/TagPrinter.d.ts.map +1 -0
- package/lib/adapter/reporter/index.d.ts +1 -0
- package/lib/adapter/reporter/index.d.ts.map +1 -0
- package/lib/adapter/reporter/index.js +5 -1
- package/lib/adapter/reporter/index.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.d.ts +28 -197
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.d.ts.map +1 -0
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js +29 -296
- package/lib/screenplay/abilities/BrowseTheWebWithWebdriverIO.js.map +1 -1
- package/lib/screenplay/abilities/index.d.ts +1 -0
- package/lib/screenplay/abilities/index.d.ts.map +1 -0
- package/lib/screenplay/abilities/index.js +5 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +1 -0
- package/lib/screenplay/index.d.ts.map +1 -0
- package/lib/screenplay/index.js +5 -1
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOBrowsingSession.d.ts +24 -0
- package/lib/screenplay/models/WebdriverIOBrowsingSession.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOBrowsingSession.js +125 -0
- package/lib/screenplay/models/WebdriverIOBrowsingSession.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOCookie.d.ts +6 -0
- package/lib/screenplay/models/WebdriverIOCookie.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOCookie.js +7 -2
- package/lib/screenplay/models/WebdriverIOCookie.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOErrorHandler.d.ts +9 -0
- package/lib/screenplay/models/WebdriverIOErrorHandler.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOErrorHandler.js +23 -0
- package/lib/screenplay/models/WebdriverIOErrorHandler.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOModalDialogHandler.d.ts +29 -0
- package/lib/screenplay/models/WebdriverIOModalDialogHandler.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOModalDialogHandler.js +77 -0
- package/lib/screenplay/models/WebdriverIOModalDialogHandler.js.map +1 -0
- package/lib/screenplay/models/WebdriverIOPage.d.ts +29 -5
- package/lib/screenplay/models/WebdriverIOPage.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOPage.js +166 -54
- package/lib/screenplay/models/WebdriverIOPage.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOPageElement.d.ts +10 -10
- package/lib/screenplay/models/WebdriverIOPageElement.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOPageElement.js +163 -117
- package/lib/screenplay/models/WebdriverIOPageElement.js.map +1 -1
- package/lib/screenplay/models/WebdriverIOPuppeteerModalDialogHandler.d.ts +32 -0
- package/lib/screenplay/models/WebdriverIOPuppeteerModalDialogHandler.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverIOPuppeteerModalDialogHandler.js +82 -0
- package/lib/screenplay/models/WebdriverIOPuppeteerModalDialogHandler.js.map +1 -0
- package/lib/screenplay/models/WebdriverProtocolErrorCode.d.ts +39 -0
- package/lib/screenplay/models/WebdriverProtocolErrorCode.d.ts.map +1 -0
- package/lib/screenplay/models/WebdriverProtocolErrorCode.js +43 -0
- package/lib/screenplay/models/WebdriverProtocolErrorCode.js.map +1 -0
- package/lib/screenplay/models/index.d.ts +2 -1
- package/lib/screenplay/models/index.d.ts.map +1 -0
- package/lib/screenplay/models/index.js +6 -2
- package/lib/screenplay/models/index.js.map +1 -1
- package/lib/screenplay/models/locators/WebdriverIOLocator.d.ts +18 -5
- package/lib/screenplay/models/locators/WebdriverIOLocator.d.ts.map +1 -0
- package/lib/screenplay/models/locators/WebdriverIOLocator.js +84 -5
- package/lib/screenplay/models/locators/WebdriverIOLocator.js.map +1 -1
- package/lib/screenplay/models/locators/WebdriverIORootLocator.d.ts +17 -0
- package/lib/screenplay/models/locators/WebdriverIORootLocator.d.ts.map +1 -0
- package/lib/screenplay/models/locators/WebdriverIORootLocator.js +32 -0
- package/lib/screenplay/models/locators/WebdriverIORootLocator.js.map +1 -0
- package/lib/screenplay/models/locators/index.d.ts +2 -1
- package/lib/screenplay/models/locators/index.d.ts.map +1 -0
- package/lib/screenplay/models/locators/index.js +6 -2
- package/lib/screenplay/models/locators/index.js.map +1 -1
- package/package.json +31 -32
- package/src/adapter/TestRunnerLoader.ts +3 -5
- package/src/adapter/WebdriverIOConfig.ts +114 -109
- package/src/adapter/WebdriverIOFrameworkAdapter.ts +20 -12
- package/src/adapter/WebdriverIOFrameworkAdapterFactory.ts +1 -1
- package/src/adapter/WebdriverIONotifier.ts +8 -6
- package/src/adapter/index.ts +0 -1
- package/src/adapter/reporter/OutputStreamBuffer.ts +1 -1
- package/src/adapter/reporter/OutputStreamBufferPrinter.ts +1 -1
- package/src/adapter/reporter/ProvidesWriteStream.ts +1 -1
- package/src/screenplay/abilities/BrowseTheWebWithWebdriverIO.ts +29 -339
- package/src/screenplay/models/WebdriverIOBrowsingSession.ts +171 -0
- package/src/screenplay/models/WebdriverIOCookie.ts +7 -2
- package/src/screenplay/models/WebdriverIOErrorHandler.ts +25 -0
- package/src/screenplay/models/WebdriverIOModalDialogHandler.ts +100 -0
- package/src/screenplay/models/WebdriverIOPage.ts +222 -63
- package/src/screenplay/models/WebdriverIOPageElement.ts +183 -148
- package/src/screenplay/models/WebdriverIOPuppeteerModalDialogHandler.ts +97 -0
- package/src/screenplay/models/WebdriverProtocolErrorCode.ts +38 -0
- package/src/screenplay/models/index.ts +1 -1
- package/src/screenplay/models/locators/WebdriverIOLocator.ts +122 -24
- package/src/screenplay/models/locators/WebdriverIORootLocator.ts +33 -0
- package/src/screenplay/models/locators/index.ts +1 -1
- package/tsconfig.build.json +17 -0
- package/lib/screenplay/models/WebdriverIOModalDialog.d.ts +0 -11
- package/lib/screenplay/models/WebdriverIOModalDialog.js +0 -40
- package/lib/screenplay/models/WebdriverIOModalDialog.js.map +0 -1
- package/lib/screenplay/models/locators/WebdriverIONativeElementRoot.d.ts +0 -2
- package/lib/screenplay/models/locators/WebdriverIONativeElementRoot.js +0 -3
- package/lib/screenplay/models/locators/WebdriverIONativeElementRoot.js.map +0 -1
- package/src/screenplay/models/WebdriverIOModalDialog.ts +0 -45
- package/src/screenplay/models/locators/WebdriverIONativeElementRoot.ts +0 -3
- package/tsconfig.eslint.json +0 -10
|
@@ -1,319 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BrowseTheWebWithWebdriverIO = void 0;
|
|
4
|
-
const core_1 = require("@serenity-js/core");
|
|
5
4
|
const web_1 = require("@serenity-js/web");
|
|
6
5
|
const models_1 = require("../models");
|
|
7
|
-
const locators_1 = require("../models/locators");
|
|
8
6
|
/**
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
11
|
-
* to interact with Web apps using [WebdriverIO](https://webdriver.io/).
|
|
7
|
+
* This implementation of the {@apilink Ability|ability} to {@apilink BrowseTheWeb}
|
|
8
|
+
* enables the {@apilink Actor} to interact with web front-ends using [WebdriverIO](https://webdriver.io/).
|
|
12
9
|
*
|
|
13
|
-
*
|
|
14
|
-
* This means that its interface can change without affecting the major version of Serenity/JS itself.
|
|
15
|
-
* In particular, please don't rely on the `browser` field to remain `public` in future releases.
|
|
10
|
+
* ## Using WebdriverIO to `BrowseTheWeb`
|
|
16
11
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
14
|
+
* import { BrowseTheWebWithWebdriverIO } from '@serenity-js/webdriverio'
|
|
15
|
+
* import { By, Navigate, PageElement, Text } from '@serenity-js/web'
|
|
16
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
21
17
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
18
|
+
* const HomePage = {
|
|
19
|
+
* title: () =>
|
|
20
|
+
* PageElement.located(By.css('h1')).describedAs('title')
|
|
21
|
+
* }
|
|
25
22
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* await actorCalled('Wendy')
|
|
24
|
+
* .whoCan(BrowseTheWebWithWebdriverIO.using(browser)) // `browser` is global in WebdriverIO tests
|
|
25
|
+
* .attemptsTo(
|
|
26
|
+
* Navigate.to(`https://serenity-js.org`),
|
|
27
|
+
* Ensure.that(Text.of(HomePage.title()), equals('Serenity/JS')),
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
29
30
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* ## Learn more
|
|
32
|
+
* - [WebdriverIO website](https://webdriver.io/)
|
|
33
|
+
* - {@apilink BrowseTheWeb}
|
|
34
|
+
* - {@apilink Ability}
|
|
35
|
+
* - {@apilink Actor}
|
|
34
36
|
*
|
|
35
|
-
* @
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
* @implements {@serenity-js/core/lib/screenplay~Ability}
|
|
39
|
-
* @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
|
|
37
|
+
* @group Abilities
|
|
40
38
|
*/
|
|
41
39
|
class BrowseTheWebWithWebdriverIO extends web_1.BrowseTheWeb {
|
|
42
|
-
/**
|
|
43
|
-
* @param {@wdio/types~Browser} browser
|
|
44
|
-
*/
|
|
45
|
-
constructor(browser) {
|
|
46
|
-
super(new Map()
|
|
47
|
-
.set(web_1.ByCss, (selector) => locators_1.WebdriverIOLocator.createRootLocator(this.browser, selector, selector.value))
|
|
48
|
-
.set(web_1.ByCssContainingText, (selector) => locators_1.WebdriverIOLocator.createRootLocator(this.browser, selector, `${selector.value}*=${selector.text}`))
|
|
49
|
-
.set(web_1.ById, (selector) => locators_1.WebdriverIOLocator.createRootLocator(this.browser, selector, `#${selector.value}`))
|
|
50
|
-
.set(web_1.ByTagName, (selector) => locators_1.WebdriverIOLocator.createRootLocator(this.browser, selector, `<${selector.value} />`))
|
|
51
|
-
.set(web_1.ByXPath, (selector) => locators_1.WebdriverIOLocator.createRootLocator(this.browser, selector, selector.value)));
|
|
52
|
-
this.browser = browser;
|
|
53
|
-
if (!this.browser.$ || !this.browser.$$) {
|
|
54
|
-
throw new core_1.LogicError(`WebdriverIO browser object is not initialised yet, so can't be assigned to an actor. Are you trying to instantiate an actor outside of a test or a test hook?`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @param {@wdio/types~Browser} browserInstance
|
|
59
|
-
* @returns {BrowseTheWebWithWebdriverIO}
|
|
60
|
-
*/
|
|
61
40
|
static using(browserInstance) {
|
|
62
41
|
return new BrowseTheWebWithWebdriverIO(browserInstance);
|
|
63
42
|
}
|
|
43
|
+
constructor(browser) {
|
|
44
|
+
super(new models_1.WebdriverIOBrowsingSession(browser));
|
|
45
|
+
this.browser = browser;
|
|
46
|
+
}
|
|
64
47
|
browserCapabilities() {
|
|
65
48
|
return Promise.resolve(this.browser.capabilities);
|
|
66
49
|
}
|
|
67
|
-
async cookie(name) {
|
|
68
|
-
return new models_1.WebdriverIOCookie(this.browser, name);
|
|
69
|
-
}
|
|
70
|
-
async setCookie(cookieData) {
|
|
71
|
-
return this.browser.setCookies({
|
|
72
|
-
name: cookieData.name,
|
|
73
|
-
value: cookieData.value,
|
|
74
|
-
path: cookieData.path,
|
|
75
|
-
domain: cookieData.domain,
|
|
76
|
-
secure: cookieData.secure,
|
|
77
|
-
httpOnly: cookieData.httpOnly,
|
|
78
|
-
expiry: cookieData.expiry
|
|
79
|
-
? cookieData.expiry.toSeconds()
|
|
80
|
-
: undefined,
|
|
81
|
-
sameSite: cookieData.sameSite,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
deleteAllCookies() {
|
|
85
|
-
return this.browser.deleteCookies();
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @desc
|
|
89
|
-
* Navigate to a given destination, specified as an absolute URL
|
|
90
|
-
* or a path relative to WebdriverIO `baseUrl`.
|
|
91
|
-
*
|
|
92
|
-
* @param {string} destination
|
|
93
|
-
* @returns {Promise<void>}
|
|
94
|
-
*/
|
|
95
|
-
navigateTo(destination) {
|
|
96
|
-
return this.browser.url(destination); // todo: check if this returns a string or is mistyped
|
|
97
|
-
}
|
|
98
|
-
navigateBack() {
|
|
99
|
-
return this.browser.back();
|
|
100
|
-
}
|
|
101
|
-
navigateForward() {
|
|
102
|
-
return this.browser.forward();
|
|
103
|
-
}
|
|
104
|
-
reloadPage() {
|
|
105
|
-
return this.browser.refresh();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* @desc
|
|
109
|
-
* Returns a {@link Page} representing the currently active top-level browsing context.
|
|
110
|
-
*
|
|
111
|
-
* @returns {Promise<Page>}
|
|
112
|
-
*/
|
|
113
|
-
async currentPage() {
|
|
114
|
-
const windowHandle = await this.browser.getWindowHandle();
|
|
115
|
-
return new models_1.WebdriverIOPage(this.browser, windowHandle);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* @desc
|
|
119
|
-
* Returns an array of {@link Page} objects representing all the available
|
|
120
|
-
* top-level browsing context, e.g. all the open browser tabs.
|
|
121
|
-
*
|
|
122
|
-
* @returns {Promise<Array<Page>>}
|
|
123
|
-
*/
|
|
124
|
-
async allPages() {
|
|
125
|
-
const windowHandles = await this.browser.getWindowHandles();
|
|
126
|
-
return windowHandles.map(windowHandle => new models_1.WebdriverIOPage(this.browser, windowHandle));
|
|
127
|
-
}
|
|
128
|
-
async modalDialog() {
|
|
129
|
-
return new models_1.WebdriverIOModalDialog(this.browser);
|
|
130
|
-
}
|
|
131
|
-
// todo: remove
|
|
132
|
-
switchToFrame(targetOrIndex) {
|
|
133
|
-
throw new Error('Not implemented, yet');
|
|
134
|
-
}
|
|
135
|
-
// todo: remove
|
|
136
|
-
switchToParentFrame() {
|
|
137
|
-
throw new Error('Not implemented, yet');
|
|
138
|
-
}
|
|
139
|
-
// todo: remove
|
|
140
|
-
switchToDefaultContent() {
|
|
141
|
-
throw new Error('Not implemented, yet');
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @desc
|
|
145
|
-
* Send a sequence of {@link Key} strokes to the active element.
|
|
146
|
-
*
|
|
147
|
-
* @param {Array<Key | string>} keys
|
|
148
|
-
* Keys to enter
|
|
149
|
-
*
|
|
150
|
-
* @returns {Promise<void>}
|
|
151
|
-
*
|
|
152
|
-
* @see https://webdriver.io/docs/api/browser/keys/
|
|
153
|
-
*/
|
|
154
|
-
sendKeys(keys) {
|
|
155
|
-
const keySequence = keys.map(key => {
|
|
156
|
-
if (!web_1.Key.isKey(key)) {
|
|
157
|
-
return key;
|
|
158
|
-
}
|
|
159
|
-
if (this.browser.isDevTools) {
|
|
160
|
-
return key.devtoolsName;
|
|
161
|
-
}
|
|
162
|
-
return key.utf16codePoint;
|
|
163
|
-
});
|
|
164
|
-
return this.browser.keys(keySequence);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @desc
|
|
168
|
-
* Take a screenshot of the top-level browsing context's viewport.
|
|
169
|
-
*
|
|
170
|
-
* @return {Promise<string>}
|
|
171
|
-
* A promise that will resolve to a base64-encoded screenshot PNG
|
|
172
|
-
*/
|
|
173
|
-
takeScreenshot() {
|
|
174
|
-
return this.browser.takeScreenshot();
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @desc
|
|
178
|
-
* Schedules a command to execute JavaScript in the context of the currently selected frame or window.
|
|
179
|
-
* The script fragment will be executed as the body of an anonymous function.
|
|
180
|
-
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
181
|
-
* into the target window.
|
|
182
|
-
*
|
|
183
|
-
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
184
|
-
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string` or `WebElement`.
|
|
185
|
-
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
186
|
-
* to the types previously mentioned.
|
|
187
|
-
*
|
|
188
|
-
* The script may refer to any variables accessible from the current window.
|
|
189
|
-
* Furthermore, the script will execute in the window's context, thus `document` may be used to refer
|
|
190
|
-
* to the current document. Any local variables will not be available once the script has finished executing,
|
|
191
|
-
* though global variables will persist.
|
|
192
|
-
*
|
|
193
|
-
* If the script has a return value (i.e. if the script contains a `return` statement),
|
|
194
|
-
* then the following steps will be taken for resolving this functions return value:
|
|
195
|
-
*
|
|
196
|
-
* For a HTML element, the value will resolve to a WebElement
|
|
197
|
-
* - Null and undefined return values will resolve to null
|
|
198
|
-
* - Booleans, numbers, and strings will resolve as is
|
|
199
|
-
* - Functions will resolve to their string representation
|
|
200
|
-
* - For arrays and objects, each member item will be converted according to the rules above
|
|
201
|
-
*
|
|
202
|
-
* @example <caption>Perform a sleep in the browser under test</caption>
|
|
203
|
-
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
204
|
-
* return arguments[0].tagName;
|
|
205
|
-
* `, Target.the('header').located(by.css(h1))
|
|
206
|
-
*
|
|
207
|
-
* @see https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeScript-java.lang.String-java.lang.Object...-
|
|
208
|
-
*
|
|
209
|
-
* @param {string | Function} script
|
|
210
|
-
* @param {any[]} args
|
|
211
|
-
*
|
|
212
|
-
* @returns {Promise<any>}
|
|
213
|
-
*
|
|
214
|
-
* @see {@link BrowseTheWeb#getLastScriptExecutionResult}
|
|
215
|
-
*/
|
|
216
|
-
async executeScript(script, ...args) {
|
|
217
|
-
const nativeArguments = await Promise.all(args.map(arg => arg instanceof models_1.WebdriverIOPageElement ? arg.nativeElement() : arg));
|
|
218
|
-
return this.browser.execute(script, ...nativeArguments)
|
|
219
|
-
.then(result => {
|
|
220
|
-
this.lastScriptExecutionSummary = new LastScriptExecutionSummary(result);
|
|
221
|
-
return result;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* @desc
|
|
226
|
-
* Schedules a command to execute asynchronous JavaScript in the context of the currently selected frame or window.
|
|
227
|
-
* The script fragment will be executed as the body of an anonymous function.
|
|
228
|
-
* If the script is provided as a function object, that function will be converted to a string for injection
|
|
229
|
-
* into the target window.
|
|
230
|
-
*
|
|
231
|
-
* Any arguments provided in addition to the script will be included as script arguments and may be referenced
|
|
232
|
-
* using the `arguments` object. Arguments may be a `boolean`, `number`, `string` or `WebElement`
|
|
233
|
-
* Arrays and objects may also be used as script arguments as long as each item adheres
|
|
234
|
-
* to the types previously mentioned.
|
|
235
|
-
*
|
|
236
|
-
* Unlike executing synchronous JavaScript with {@link BrowseTheWebWithWebdriverIO#executeScript},
|
|
237
|
-
* scripts executed with this function must explicitly signal they are finished by invoking the provided callback.
|
|
238
|
-
*
|
|
239
|
-
* This callback will always be injected into the executed function as the last argument,
|
|
240
|
-
* and thus may be referenced with `arguments[arguments.length - 1]`.
|
|
241
|
-
*
|
|
242
|
-
* The following steps will be taken for resolving this functions return value against
|
|
243
|
-
* the first argument to the script's callback function:
|
|
244
|
-
*
|
|
245
|
-
* - For a HTML element, the value will resolve to a WebElement
|
|
246
|
-
* - Null and undefined return values will resolve to null
|
|
247
|
-
* - Booleans, numbers, and strings will resolve as is
|
|
248
|
-
* - Functions will resolve to their string representation
|
|
249
|
-
* - For arrays and objects, each member item will be converted according to the rules above
|
|
250
|
-
*
|
|
251
|
-
* @example <caption>Perform a sleep in the browser under test</caption>
|
|
252
|
-
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
253
|
-
* var delay = arguments[0];
|
|
254
|
-
* var callback = arguments[arguments.length - 1];
|
|
255
|
-
*
|
|
256
|
-
* window.setTimeout(callback, delay);
|
|
257
|
-
* `, 500)
|
|
258
|
-
*
|
|
259
|
-
* @example <caption>Return a value asynchronously</caption>
|
|
260
|
-
* BrowseTheWeb.as(actor).executeAsyncScript(`
|
|
261
|
-
* var callback = arguments[arguments.length - 1];
|
|
262
|
-
*
|
|
263
|
-
* callback('some return value')
|
|
264
|
-
* `).then(value => doSomethingWithThe(value))
|
|
265
|
-
*
|
|
266
|
-
* @see https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html#executeAsyncScript-java.lang.String-java.lang.Object...-
|
|
267
|
-
*
|
|
268
|
-
* @param {string|Function} script
|
|
269
|
-
* @param {any[]} args
|
|
270
|
-
*
|
|
271
|
-
* @returns {Promise<any>}
|
|
272
|
-
*
|
|
273
|
-
* @see {@link BrowseTheWeb#getLastScriptExecutionResult}
|
|
274
|
-
*/
|
|
275
|
-
async executeAsyncScript(script, ...args) {
|
|
276
|
-
const nativeArguments = await Promise.all(args.map(arg => arg instanceof models_1.WebdriverIOPageElement ? arg.nativeElement() : arg));
|
|
277
|
-
return this.browser.executeAsync(script, ...nativeArguments)
|
|
278
|
-
.then(result => {
|
|
279
|
-
this.lastScriptExecutionSummary = new LastScriptExecutionSummary(result);
|
|
280
|
-
return result;
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* @desc
|
|
285
|
-
* Returns the last result of calling {@link BrowseTheWebWithWebdriverIO#executeAsyncScript}
|
|
286
|
-
* or {@link BrowseTheWebWithWebdriverIO#executeScript}
|
|
287
|
-
*
|
|
288
|
-
* @returns {any}
|
|
289
|
-
*/
|
|
290
|
-
lastScriptExecutionResult() {
|
|
291
|
-
if (!this.lastScriptExecutionSummary) {
|
|
292
|
-
throw new core_1.LogicError(`Make sure to execute a script before checking on the result`);
|
|
293
|
-
}
|
|
294
|
-
// Selenium returns `null` when the script it executed returns `undefined`
|
|
295
|
-
// so we're mapping the result back.
|
|
296
|
-
return this.lastScriptExecutionSummary.result !== null
|
|
297
|
-
? this.lastScriptExecutionSummary.result
|
|
298
|
-
: undefined;
|
|
299
|
-
}
|
|
300
|
-
waitFor(duration) {
|
|
301
|
-
return this.browser.pause(duration.inMilliseconds());
|
|
302
|
-
}
|
|
303
|
-
waitUntil(condition, timeout) {
|
|
304
|
-
return this.browser.waitUntil(condition, {
|
|
305
|
-
timeout: timeout.inMilliseconds(),
|
|
306
|
-
timeoutMsg: `Wait timed out after ${timeout}`,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
50
|
}
|
|
310
51
|
exports.BrowseTheWebWithWebdriverIO = BrowseTheWebWithWebdriverIO;
|
|
311
|
-
/**
|
|
312
|
-
* @package
|
|
313
|
-
*/
|
|
314
|
-
class LastScriptExecutionSummary {
|
|
315
|
-
constructor(result) {
|
|
316
|
-
this.result = result;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
52
|
//# sourceMappingURL=BrowseTheWebWithWebdriverIO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowseTheWebWithWebdriverIO.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithWebdriverIO.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"BrowseTheWebWithWebdriverIO.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/BrowseTheWebWithWebdriverIO.ts"],"names":[],"mappings":";;;AAAA,0CAAqE;AAGrE,sCAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAa,2BAA4B,SAAQ,kBAAmC;IAEhF,MAAM,CAAC,KAAK,CAAC,eAAsC;QAC/C,OAAO,IAAI,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC;IAED,YAA+B,OAA8B;QACzD,KAAK,CAAC,IAAI,mCAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;QADpB,YAAO,GAAP,OAAO,CAAuB;IAE7D,CAAC;IAED,mBAAmB;QACf,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAmC,CAAC,CAAC;IAC7E,CAAC;CACJ;AAbD,kEAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/abilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/lib/screenplay/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screenplay/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BrowsingSession } from '@serenity-js/web';
|
|
2
|
+
import * as wdio from 'webdriverio';
|
|
3
|
+
import { WebdriverIOPage } from '../models';
|
|
4
|
+
/**
|
|
5
|
+
* WebdriverIO-specific implementation of {@apilink BrowsingSession}.
|
|
6
|
+
*
|
|
7
|
+
* @group Models
|
|
8
|
+
*/
|
|
9
|
+
export declare class WebdriverIOBrowsingSession extends BrowsingSession<WebdriverIOPage> {
|
|
10
|
+
protected readonly browser: wdio.Browser<'async'>;
|
|
11
|
+
constructor(browser: wdio.Browser<'async'>);
|
|
12
|
+
allPages(): Promise<Array<WebdriverIOPage>>;
|
|
13
|
+
/**
|
|
14
|
+
* @override
|
|
15
|
+
* @param page
|
|
16
|
+
*/
|
|
17
|
+
changeCurrentPageTo(page: WebdriverIOPage): Promise<void>;
|
|
18
|
+
private activeWindowHandle;
|
|
19
|
+
currentPage(): Promise<WebdriverIOPage>;
|
|
20
|
+
protected registerCurrentPage(): Promise<WebdriverIOPage>;
|
|
21
|
+
private modalDialogHandlerFor;
|
|
22
|
+
private puppeteerPageFor;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=WebdriverIOBrowsingSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebdriverIOBrowsingSession.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIOBrowsingSession.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,eAAe,CAAC,eAAe,CAAC;IAEhE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAA9B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAQvD,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IA8BjD;;;OAGG;IACG,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAoBjD,kBAAkB;IAmBjB,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;cAwBtC,mBAAmB,IAAI,OAAO,CAAC,eAAe,CAAC;YAkBjD,qBAAqB;YAMrB,gBAAgB;CAuBjC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebdriverIOBrowsingSession = void 0;
|
|
4
|
+
const core_1 = require("@serenity-js/core");
|
|
5
|
+
const model_1 = require("@serenity-js/core/lib/model");
|
|
6
|
+
const web_1 = require("@serenity-js/web");
|
|
7
|
+
const models_1 = require("../models");
|
|
8
|
+
const WebdriverIOErrorHandler_1 = require("./WebdriverIOErrorHandler");
|
|
9
|
+
const WebdriverIOModalDialogHandler_1 = require("./WebdriverIOModalDialogHandler");
|
|
10
|
+
const WebdriverIOPuppeteerModalDialogHandler_1 = require("./WebdriverIOPuppeteerModalDialogHandler");
|
|
11
|
+
/**
|
|
12
|
+
* WebdriverIO-specific implementation of {@apilink BrowsingSession}.
|
|
13
|
+
*
|
|
14
|
+
* @group Models
|
|
15
|
+
*/
|
|
16
|
+
class WebdriverIOBrowsingSession extends web_1.BrowsingSession {
|
|
17
|
+
constructor(browser) {
|
|
18
|
+
super();
|
|
19
|
+
this.browser = browser;
|
|
20
|
+
if (!browser.$ || !browser.$$) {
|
|
21
|
+
throw new core_1.LogicError(`WebdriverIO browser object is not initialised yet, so can't be assigned to an actor. Are you trying to instantiate an actor outside of a test or a test hook?`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async allPages() {
|
|
25
|
+
// scan all the active window handles and add any newly opened windows if needed
|
|
26
|
+
const windowHandles = await this.browser.getWindowHandles();
|
|
27
|
+
// remove pages that are no longer open
|
|
28
|
+
const closedPageIds = this.registeredPageIds()
|
|
29
|
+
.filter(id => !windowHandles.includes(id.value));
|
|
30
|
+
this.deregister(...closedPageIds);
|
|
31
|
+
// add any new pages that might have been opened (e.g. popup windows)
|
|
32
|
+
const registeredWindowHandles = new Set(this.registeredPageIds().map(id => id.value));
|
|
33
|
+
const newlyOpenedWindowHandles = windowHandles.filter(windowHandle => !registeredWindowHandles.has(windowHandle));
|
|
34
|
+
for (const newlyOpenedWindowHandle of newlyOpenedWindowHandles) {
|
|
35
|
+
const errorHandler = new WebdriverIOErrorHandler_1.WebdriverIOErrorHandler();
|
|
36
|
+
this.register(new models_1.WebdriverIOPage(this, this.browser, await this.modalDialogHandlerFor(newlyOpenedWindowHandle, errorHandler), errorHandler, new model_1.CorrelationId(newlyOpenedWindowHandle)));
|
|
37
|
+
}
|
|
38
|
+
return super.allPages();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
* @param page
|
|
43
|
+
*/
|
|
44
|
+
async changeCurrentPageTo(page) {
|
|
45
|
+
const currentPage = await this.currentPage();
|
|
46
|
+
// are we already on this page?
|
|
47
|
+
if (currentPage.id.equals(page.id)) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
// does the new page exist, or has it been closed in the meantime by user action, script, or similar?
|
|
51
|
+
if (!await page.isPresent()) {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
// the page seems to be legit, switch to it
|
|
55
|
+
await this.browser.switchToWindow(page.id.value);
|
|
56
|
+
// and update the cached reference
|
|
57
|
+
await super.changeCurrentPageTo(page);
|
|
58
|
+
}
|
|
59
|
+
async activeWindowHandle() {
|
|
60
|
+
try {
|
|
61
|
+
return await this.browser.getWindowHandle();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// If the window is closed by user action Webdriver will still hold the reference to the closed window.
|
|
65
|
+
if (['NoSuchWindowError', 'no such window'].includes(error.name)) {
|
|
66
|
+
const allHandles = await this.browser.getWindowHandles();
|
|
67
|
+
if (allHandles.length > 0) {
|
|
68
|
+
const handle = allHandles[allHandles.length - 1];
|
|
69
|
+
await this.browser.switchToWindow(handle);
|
|
70
|
+
return handle;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async currentPage() {
|
|
77
|
+
const actualCurrentPageHandle = await this.activeWindowHandle();
|
|
78
|
+
const actualCurrentPageId = model_1.CorrelationId.fromJSON(actualCurrentPageHandle);
|
|
79
|
+
if (this.currentBrowserPage && this.currentBrowserPage.id.equals(actualCurrentPageId)) {
|
|
80
|
+
return this.currentBrowserPage;
|
|
81
|
+
}
|
|
82
|
+
// Looks like the actual current page is not what we thought the current page was.
|
|
83
|
+
// Is it one of the pages we are aware of?
|
|
84
|
+
const allPages = await this.allPages();
|
|
85
|
+
const found = allPages.find(page => page.id.equals(actualCurrentPageId));
|
|
86
|
+
if (found) {
|
|
87
|
+
this.currentBrowserPage = found;
|
|
88
|
+
return this.currentBrowserPage;
|
|
89
|
+
}
|
|
90
|
+
// OK, so that's a handle that we haven't seen before, let's register it and set as current page.
|
|
91
|
+
this.currentBrowserPage = await this.registerCurrentPage();
|
|
92
|
+
return this.currentBrowserPage;
|
|
93
|
+
}
|
|
94
|
+
async registerCurrentPage() {
|
|
95
|
+
const windowHandle = await this.browser.getWindowHandle();
|
|
96
|
+
const errorHandler = new WebdriverIOErrorHandler_1.WebdriverIOErrorHandler();
|
|
97
|
+
const page = new models_1.WebdriverIOPage(this, this.browser, await this.modalDialogHandlerFor(windowHandle, errorHandler), errorHandler, new model_1.CorrelationId(windowHandle));
|
|
98
|
+
this.register(page);
|
|
99
|
+
return page;
|
|
100
|
+
}
|
|
101
|
+
async modalDialogHandlerFor(windowHandle, errorHandler) {
|
|
102
|
+
return this.browser.isDevTools
|
|
103
|
+
? new WebdriverIOPuppeteerModalDialogHandler_1.WebdriverIOPuppeteerModalDialogHandler(await this.puppeteerPageFor(windowHandle))
|
|
104
|
+
: new WebdriverIOModalDialogHandler_1.WebdriverIOModalDialogHandler(this.browser, errorHandler);
|
|
105
|
+
}
|
|
106
|
+
async puppeteerPageFor(windowHandle) {
|
|
107
|
+
const puppeteer = await this.browser.getPuppeteer();
|
|
108
|
+
const pages = await puppeteer.pages();
|
|
109
|
+
const handles = await this.browser.getWindowHandles();
|
|
110
|
+
if (handles.length !== pages.length) {
|
|
111
|
+
throw new core_1.LogicError(`The number of registered Puppeteer pages doesn't match WebdriverIO window handles.`);
|
|
112
|
+
}
|
|
113
|
+
const index = handles.indexOf(windowHandle);
|
|
114
|
+
// We cast to `unknown` first because the version of Page in Puppeteer-core
|
|
115
|
+
// might be slightly out-of-sync with what the WebdriverIO uses.
|
|
116
|
+
// This doesn't really matter since we're only using it to work with Dialogs.
|
|
117
|
+
const page = pages[index];
|
|
118
|
+
if (!page) {
|
|
119
|
+
throw new core_1.LogicError(`Couldn't find Puppeteer page for WebdriverIO window handle ${windowHandle}.`);
|
|
120
|
+
}
|
|
121
|
+
return page;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.WebdriverIOBrowsingSession = WebdriverIOBrowsingSession;
|
|
125
|
+
//# sourceMappingURL=WebdriverIOBrowsingSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebdriverIOBrowsingSession.js","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIOBrowsingSession.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAC/C,uDAA4D;AAC5D,0CAAuE;AAIvE,sCAA4C;AAC5C,uEAAoE;AACpE,mFAAgF;AAChF,qGAAkG;AAElG;;;;GAIG;AACH,MAAa,0BAA2B,SAAQ,qBAAgC;IAE5E,YAA+B,OAA8B;QACzD,KAAK,EAAE,CAAC;QADmB,YAAO,GAAP,OAAO,CAAuB;QAGzD,IAAI,CAAE,OAAO,CAAC,CAAC,IAAI,CAAE,OAAO,CAAC,EAAE,EAAE;YAC7B,MAAM,IAAI,iBAAU,CAAC,+JAA+J,CAAC,CAAA;SACxL;IACL,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,gFAAgF;QAChF,MAAM,aAAa,GAAa,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAEtE,uCAAuC;QACvC,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,EAAE;aACzC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAEtD,IAAI,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,CAAC;QAElC,qEAAqE;QACrE,MAAM,uBAAuB,GAAK,IAAI,GAAG,CAAC,I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;QAC3E,gEAAgE;QAChE,6EAA6E;QAC7E,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAoB,CAAC;QAE7C,IAAI,CAAE,IAAI,EAAE;YACR,MAAM,IAAI,iBAAU,CAAC,8DAA+D,YAAa,GAAG,CAAC,CAAA;SACxG;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA1JD,gEA0JC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Cookie, CookieData } from '@serenity-js/web';
|
|
2
2
|
import * as wdio from 'webdriverio';
|
|
3
|
+
/**
|
|
4
|
+
* WebdriverIO-specific implementation of {@apilink Cookie}.
|
|
5
|
+
*
|
|
6
|
+
* @group Models
|
|
7
|
+
*/
|
|
3
8
|
export declare class WebdriverIOCookie extends Cookie {
|
|
4
9
|
private readonly browser;
|
|
5
10
|
constructor(browser: wdio.Browser<'async'>, cookieName: string);
|
|
6
11
|
delete(): Promise<void>;
|
|
7
12
|
protected read(): Promise<CookieData>;
|
|
8
13
|
}
|
|
14
|
+
//# sourceMappingURL=WebdriverIOCookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebdriverIOCookie.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/WebdriverIOCookie.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAsB,MAAM,kBAAkB,CAAC;AAE1E,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,MAAM;IAGrC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAC/C,UAAU,EAAE,MAAM;IAMhB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;cAIb,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;CAwB9C"}
|
|
@@ -4,6 +4,11 @@ exports.WebdriverIOCookie = void 0;
|
|
|
4
4
|
const core_1 = require("@serenity-js/core");
|
|
5
5
|
const web_1 = require("@serenity-js/web");
|
|
6
6
|
const tiny_types_1 = require("tiny-types");
|
|
7
|
+
/**
|
|
8
|
+
* WebdriverIO-specific implementation of {@apilink Cookie}.
|
|
9
|
+
*
|
|
10
|
+
* @group Models
|
|
11
|
+
*/
|
|
7
12
|
class WebdriverIOCookie extends web_1.Cookie {
|
|
8
13
|
constructor(browser, cookieName) {
|
|
9
14
|
super(cookieName);
|
|
@@ -11,7 +16,7 @@ class WebdriverIOCookie extends web_1.Cookie {
|
|
|
11
16
|
(0, tiny_types_1.ensure)('browser', browser, (0, tiny_types_1.isDefined)());
|
|
12
17
|
}
|
|
13
18
|
async delete() {
|
|
14
|
-
|
|
19
|
+
await this.browser.deleteCookies(this.cookieName);
|
|
15
20
|
}
|
|
16
21
|
async read() {
|
|
17
22
|
const [cookie] = await this.browser.getCookies(this.cookieName);
|
|
@@ -27,7 +32,7 @@ class WebdriverIOCookie extends web_1.Cookie {
|
|
|
27
32
|
value: cookie.value,
|
|
28
33
|
domain: cookie.domain,
|
|
29
34
|
path: cookie.path,
|
|
30
|
-
expiry: expiry
|
|
35
|
+
expiry: typeof expiry === 'number' && expiry >= 0
|
|
31
36
|
? core_1.Timestamp.fromTimestampInSeconds(Math.round(expiry))
|
|
32
37
|
: undefined,
|
|
33
38
|
httpOnly: cookie.httpOnly,
|
|
@@ -1 +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,sBA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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,9 @@
|
|
|
1
|
+
import { WebdriverProtocolErrorCode } from './WebdriverProtocolErrorCode';
|
|
2
|
+
export declare class WebdriverIOErrorHandler {
|
|
3
|
+
private readonly handlers;
|
|
4
|
+
constructor(handlers?: Map<WebdriverProtocolErrorCode, (error: Error) => Promise<void> | void>);
|
|
5
|
+
executeIfHandled<T>(error: Error, action: () => Promise<T> | T): Promise<T>;
|
|
6
|
+
setHandlerFor(errorType: WebdriverProtocolErrorCode, handler: (error: Error) => Promise<void> | void): void;
|
|
7
|
+
unsetHandlerFor(errorType: WebdriverProtocolErrorCode): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=WebdriverIOErrorHandler.d.ts.map
|