@applitools/driver 1.2.6 → 1.3.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 +24 -0
- package/dist/capabilities.js +54 -0
- package/dist/context.js +7 -0
- package/dist/driver.js +42 -15
- package/dist/element.js +13 -5
- package/dist/fake/index.js +25 -0
- package/dist/fake/mock-driver.js +7 -2
- package/dist/fake/spec-driver.js +103 -65
- package/dist/index.js +0 -15
- package/package.json +16 -9
- package/types/capabilities.d.ts +4 -0
- package/types/context.d.ts +1 -0
- package/types/driver.d.ts +2 -0
- package/types/fake/index.d.ts +3 -0
- package/types/fake/mock-driver.d.ts +7 -43
- package/types/fake/spec-driver.d.ts +29 -40
- package/types/index.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## 1.3.2 - 2021/11/14
|
|
7
|
+
|
|
8
|
+
- adjust scrolling algorithm on native devices
|
|
9
|
+
|
|
10
|
+
## 1.3.1 - 2021/11/14
|
|
11
|
+
|
|
12
|
+
- add in-house capability parsing and system bars size handling mechanisms
|
|
13
|
+
- adjust scrolling algorithm on native devices
|
|
14
|
+
- support cookies
|
|
15
|
+
- updated to @applitools/types@1.0.20 (from 1.0.19)
|
|
16
|
+
|
|
17
|
+
## 1.3.0 - 2021/11/10
|
|
18
|
+
|
|
19
|
+
- updated to @applitools/types@1.0.19 (from 1.0.18)
|
|
20
|
+
|
|
21
|
+
## 1.3.0 - 2021/11/10
|
|
22
|
+
|
|
23
|
+
- updated to @applitools/types@1.0.19 (from 1.0.18)
|
|
24
|
+
|
|
25
|
+
## 1.2.7 - 2021/10/30
|
|
26
|
+
|
|
27
|
+
- updated to @applitools/types@1.0.18 (from 1.0.14)
|
|
28
|
+
- updated to @applitools/utils@1.2.4 (from 1.2.3)
|
|
29
|
+
|
|
6
30
|
## 1.2.6 - 2021/10/7
|
|
7
31
|
|
|
8
32
|
- fix issue with fractional viewport size on mobile devices
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCapabilities = void 0;
|
|
4
|
+
function parseCapabilities(capabilities) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6
|
+
const info = {
|
|
7
|
+
browserName: ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined,
|
|
8
|
+
browserVersion: ((_c = capabilities.browserVersion) !== null && _c !== void 0 ? _c : capabilities.version) || undefined,
|
|
9
|
+
platformName: ((_e = (_d = capabilities.platformName) !== null && _d !== void 0 ? _d : capabilities.platform) !== null && _e !== void 0 ? _e : (_f = capabilities.desired) === null || _f === void 0 ? void 0 : _f.platformName) || undefined,
|
|
10
|
+
platformVersion: capabilities.platformVersion || undefined,
|
|
11
|
+
isW3C: isW3C(capabilities),
|
|
12
|
+
isMobile: isMobile(capabilities),
|
|
13
|
+
};
|
|
14
|
+
if (info.isMobile) {
|
|
15
|
+
info.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
|
|
16
|
+
info.isNative = info.isMobile && !info.browserName;
|
|
17
|
+
info.isIOS = isIOS(capabilities);
|
|
18
|
+
info.isAndroid = isAndroid(capabilities);
|
|
19
|
+
}
|
|
20
|
+
if (info.isNative) {
|
|
21
|
+
info.pixelRatio = capabilities.pixelRatio;
|
|
22
|
+
info.statusBarHeight = capabilities.statBarHeight;
|
|
23
|
+
info.navigationBarHeight = 0;
|
|
24
|
+
}
|
|
25
|
+
return info;
|
|
26
|
+
}
|
|
27
|
+
exports.parseCapabilities = parseCapabilities;
|
|
28
|
+
function isW3C(capabilities) {
|
|
29
|
+
const isW3C = Boolean((capabilities.platformName || capabilities.browserVersion) &&
|
|
30
|
+
(capabilities.platformVersion || capabilities.hasOwnProperty('setWindowRect')));
|
|
31
|
+
return isW3C || isAppium(capabilities);
|
|
32
|
+
}
|
|
33
|
+
function isAppium(capabilities) {
|
|
34
|
+
return (Boolean(capabilities.automationName || capabilities.deviceName || capabilities.appiumVersion) ||
|
|
35
|
+
Object.keys(capabilities).some(cap => cap.startsWith('appium:')));
|
|
36
|
+
}
|
|
37
|
+
function _isChrome(capabilities) {
|
|
38
|
+
return Boolean(capabilities.chrome || capabilities['goog:chromeOptions']);
|
|
39
|
+
}
|
|
40
|
+
function _isFirefox(capabilities) {
|
|
41
|
+
return capabilities.browserName === 'firefox' || Object.keys(capabilities).some(cap => cap.startsWith('moz:'));
|
|
42
|
+
}
|
|
43
|
+
function isMobile(capabilities) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return (capabilities.browserName === '' ||
|
|
46
|
+
['ipad', 'iphone', 'android'].includes((_b = (_a = capabilities.browserName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '') ||
|
|
47
|
+
isAppium(capabilities));
|
|
48
|
+
}
|
|
49
|
+
function isIOS(capabilities) {
|
|
50
|
+
return /iOS/i.test(capabilities.platformName) || /(iPad|iPhone)/i.test(capabilities.deviceName);
|
|
51
|
+
}
|
|
52
|
+
function isAndroid(capabilities) {
|
|
53
|
+
return /Android/i.test(capabilities.platformName) || /Android/i.test(capabilities.browserName);
|
|
54
|
+
}
|
package/dist/context.js
CHANGED
|
@@ -437,6 +437,13 @@ class Context {
|
|
|
437
437
|
}
|
|
438
438
|
return region;
|
|
439
439
|
}
|
|
440
|
+
async getCookies() {
|
|
441
|
+
var _a, _b;
|
|
442
|
+
if (this.driver.isNative)
|
|
443
|
+
return [];
|
|
444
|
+
await this.focus();
|
|
445
|
+
return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target, true)) !== null && _b !== void 0 ? _b : [];
|
|
446
|
+
}
|
|
440
447
|
async preserveInnerOffset() {
|
|
441
448
|
this._state.innerOffset = await this.getInnerOffset();
|
|
442
449
|
}
|
package/dist/driver.js
CHANGED
|
@@ -24,6 +24,7 @@ const utils = __importStar(require("@applitools/utils"));
|
|
|
24
24
|
const context_1 = require("./context");
|
|
25
25
|
const utils_1 = require("./utils");
|
|
26
26
|
const user_agent_1 = require("./user-agent");
|
|
27
|
+
const capabilities_1 = require("./capabilities");
|
|
27
28
|
const snippets = require('@applitools/snippets');
|
|
28
29
|
// eslint-disable-next-line
|
|
29
30
|
class Driver {
|
|
@@ -125,23 +126,43 @@ class Driver {
|
|
|
125
126
|
this._currentContext = context;
|
|
126
127
|
}
|
|
127
128
|
async init() {
|
|
128
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r
|
|
129
|
-
|
|
129
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
130
|
+
var _s, _t, _u, _v, _w, _x;
|
|
131
|
+
const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
|
|
132
|
+
this._logger.log('Driver capabilities', capabilities);
|
|
133
|
+
const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities) : undefined;
|
|
134
|
+
const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
|
|
135
|
+
this._driverInfo = Object.assign(Object.assign({}, capabilitiesInfo), driverInfo);
|
|
130
136
|
if (this.isWeb) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
(_e = (_s = this._driverInfo).pixelRatio) !== null && _e !== void 0 ? _e : (_s.pixelRatio = await this.execute(snippets.getPixelRatio));
|
|
138
|
+
(_f = (_t = this._driverInfo).userAgent) !== null && _f !== void 0 ? _f : (_t.userAgent = await this.execute(snippets.getUserAgent));
|
|
139
|
+
if (this._driverInfo.userAgent) {
|
|
140
|
+
const userAgentInfo = user_agent_1.parseUserAgent(this._driverInfo.userAgent);
|
|
141
|
+
this._driverInfo.browserName = (_g = userAgentInfo.browserName) !== null && _g !== void 0 ? _g : this._driverInfo.browserName;
|
|
142
|
+
this._driverInfo.browserVersion = (_h = userAgentInfo.browserVersion) !== null && _h !== void 0 ? _h : this._driverInfo.browserVersion;
|
|
143
|
+
if (!this._driverInfo.isMobile) {
|
|
144
|
+
(_j = (_u = this._driverInfo).platformName) !== null && _j !== void 0 ? _j : (_u.platformName = userAgentInfo.platformName);
|
|
145
|
+
(_k = (_v = this._driverInfo).platformVersion) !== null && _k !== void 0 ? _k : (_v.platformVersion = userAgentInfo.platformVersion);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this._driverInfo.platformName = (_l = userAgentInfo.platformName) !== null && _l !== void 0 ? _l : this._driverInfo.platformName;
|
|
149
|
+
this._driverInfo.platformVersion = (_m = userAgentInfo.platformVersion) !== null && _m !== void 0 ? _m : this._driverInfo.platformVersion;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
(_o = (_w = this._driverInfo).features) !== null && _o !== void 0 ? _o : (_w.features = {});
|
|
153
|
+
(_p = (_x = this._driverInfo.features).allCookies) !== null && _p !== void 0 ? _p : (_x.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
|
|
140
154
|
}
|
|
141
155
|
else {
|
|
142
|
-
if (this.
|
|
143
|
-
this.
|
|
144
|
-
|
|
156
|
+
if (this.isNative) {
|
|
157
|
+
const barsHeight = await ((_r = (_q = this._spec).getBarsHeight) === null || _r === void 0 ? void 0 : _r.call(_q, this.target).catch(() => undefined));
|
|
158
|
+
if (barsHeight) {
|
|
159
|
+
this._driverInfo.statusBarHeight = Math.max(barsHeight.statusBarHeight, driverInfo.statusBarHeight);
|
|
160
|
+
this._driverInfo.navigationBarHeight = Math.max(barsHeight.navigationBarHeight, driverInfo.navigationBarHeight);
|
|
161
|
+
}
|
|
162
|
+
if (this.isAndroid) {
|
|
163
|
+
this._driverInfo.statusBarHeight /= this.pixelRatio;
|
|
164
|
+
this._driverInfo.navigationBarHeight /= this.pixelRatio;
|
|
165
|
+
}
|
|
145
166
|
}
|
|
146
167
|
if (!this._driverInfo.viewportSize) {
|
|
147
168
|
const displaySize = await this.getDisplaySize();
|
|
@@ -151,7 +172,7 @@ class Driver {
|
|
|
151
172
|
};
|
|
152
173
|
}
|
|
153
174
|
}
|
|
154
|
-
this._logger.log('
|
|
175
|
+
this._logger.log('Combined driver info', this._driverInfo);
|
|
155
176
|
return this;
|
|
156
177
|
}
|
|
157
178
|
async refreshContexts() {
|
|
@@ -412,6 +433,12 @@ class Driver {
|
|
|
412
433
|
this._logger.log('Extracted device orientation:', orientation);
|
|
413
434
|
return orientation;
|
|
414
435
|
}
|
|
436
|
+
async getCookies() {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
if (this.isNative || !this.features.allCookies)
|
|
439
|
+
return [];
|
|
440
|
+
return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target)) !== null && _b !== void 0 ? _b : [];
|
|
441
|
+
}
|
|
415
442
|
async getTitle() {
|
|
416
443
|
if (this.isNative)
|
|
417
444
|
return null;
|
package/dist/element.js
CHANGED
|
@@ -309,36 +309,44 @@ class Element {
|
|
|
309
309
|
let remainingOffset;
|
|
310
310
|
if (offset.x === 0 && offset.y === 0) {
|
|
311
311
|
requiredOffset = offset;
|
|
312
|
-
|
|
312
|
+
// if it has to be scrolled to the very beginning, then scroll maximum amount of pixels and a bit extra to be sure
|
|
313
|
+
remainingOffset = { x: -(maxOffset.x + 0), y: -(maxOffset.y + 0) };
|
|
313
314
|
}
|
|
314
315
|
else {
|
|
315
316
|
requiredOffset = { x: Math.min(offset.x, maxOffset.x), y: Math.min(offset.y, maxOffset.y) };
|
|
316
317
|
remainingOffset = utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
|
|
318
|
+
// if it has to be scrolled to the very end, then do a bit of extra scrolling to be sure
|
|
319
|
+
// if (requiredOffset.x === maxOffset.x) remainingOffset.x += 100
|
|
320
|
+
// if (requiredOffset.y === maxOffset.y) remainingOffset.y += 100
|
|
317
321
|
}
|
|
322
|
+
// if (requiredOffset.x === 0) remainingOffset.x -= 100
|
|
323
|
+
// if (requiredOffset.y === 0) remainingOffset.y -= 100
|
|
324
|
+
// if (requiredOffset.x === maxOffset.x) remainingOffset.x += 100
|
|
325
|
+
// if (requiredOffset.y === maxOffset.y) remainingOffset.y += 100
|
|
318
326
|
if (this.driver.isAndroid) {
|
|
319
327
|
remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
|
|
320
328
|
}
|
|
321
329
|
const actions = [];
|
|
322
330
|
const xPadding = Math.floor(scrollableRegion.width * 0.1);
|
|
323
|
-
const
|
|
331
|
+
const yTrack = Math.floor(scrollableRegion.y + scrollableRegion.height / 2); // center
|
|
324
332
|
const xLeft = scrollableRegion.y + xPadding;
|
|
325
333
|
const xDirection = remainingOffset.y > 0 ? 'right' : 'left';
|
|
326
334
|
let xRemaining = Math.abs(remainingOffset.x);
|
|
327
335
|
while (xRemaining > 0) {
|
|
328
336
|
const xRight = scrollableRegion.x + Math.min(xRemaining + xPadding, scrollableRegion.width - xPadding);
|
|
329
337
|
const [xStart, xEnd] = xDirection === 'right' ? [xRight, xLeft] : [xLeft, xRight];
|
|
330
|
-
actions.push({ action: 'press', x: xStart, y:
|
|
338
|
+
actions.push({ action: 'press', x: xStart, y: yTrack }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xEnd, y: yTrack }, { action: 'release' });
|
|
331
339
|
xRemaining -= xRight - xLeft;
|
|
332
340
|
}
|
|
333
341
|
const yPadding = Math.floor(scrollableRegion.height * 0.1);
|
|
334
|
-
const
|
|
342
|
+
const xTrack = Math.floor(scrollableRegion.x + 5); // a little bit off left border
|
|
335
343
|
const yTop = scrollableRegion.y + yPadding;
|
|
336
344
|
const yDirection = remainingOffset.y > 0 ? 'down' : 'up';
|
|
337
345
|
let yRemaining = Math.abs(remainingOffset.y) + (await this.getTouchPadding()) * 2;
|
|
338
346
|
while (yRemaining > 0) {
|
|
339
347
|
const yBottom = scrollableRegion.y + Math.min(yRemaining + yPadding, scrollableRegion.height - yPadding);
|
|
340
348
|
const [yStart, yEnd] = yDirection === 'down' ? [yBottom, yTop] : [yTop, yBottom];
|
|
341
|
-
actions.push({ action: 'press', x:
|
|
349
|
+
actions.push({ action: 'press', x: xTrack, y: yStart }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xTrack, y: yEnd }, { action: 'wait', ms: 1500 }, { action: 'release' });
|
|
342
350
|
yRemaining -= yBottom - yTop;
|
|
343
351
|
}
|
|
344
352
|
if (actions.length > 0) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.spec = exports.MockDriver = void 0;
|
|
23
|
+
var mock_driver_1 = require("./mock-driver");
|
|
24
|
+
Object.defineProperty(exports, "MockDriver", { enumerable: true, get: function () { return mock_driver_1.MockDriver; } });
|
|
25
|
+
exports.spec = __importStar(require("./spec-driver"));
|
package/dist/fake/mock-driver.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MockDriver = void 0;
|
|
1
5
|
const { inspect } = require('util');
|
|
2
6
|
const utils = require('@applitools/utils');
|
|
3
7
|
const snippets = require('@applitools/snippets');
|
|
@@ -18,7 +22,8 @@ const DEFAULT_PROPS = {
|
|
|
18
22
|
overflow: null,
|
|
19
23
|
};
|
|
20
24
|
class MockDriver {
|
|
21
|
-
constructor(
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
const { viewport = { width: 1000, height: 1000 }, device, platform, browser, ua } = options;
|
|
22
27
|
this._device = device;
|
|
23
28
|
this._platform = platform;
|
|
24
29
|
this._browser = browser;
|
|
@@ -336,4 +341,4 @@ class MockDriver {
|
|
|
336
341
|
return '<MockDriver>';
|
|
337
342
|
}
|
|
338
343
|
}
|
|
339
|
-
|
|
344
|
+
exports.MockDriver = MockDriver;
|
package/dist/fake/spec-driver.js
CHANGED
|
@@ -1,66 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
executeScript(driver, script, ...args) {
|
|
22
|
-
return driver.executeScript(script, args);
|
|
23
|
-
},
|
|
24
|
-
findElement(driver, selector, parent) {
|
|
25
|
-
return driver.findElement(selector.selector || selector, parent);
|
|
26
|
-
},
|
|
27
|
-
findElements(driver, selector, parent) {
|
|
28
|
-
return driver.findElements(selector.selector || selector, parent);
|
|
29
|
-
},
|
|
30
|
-
mainContext(driver) {
|
|
31
|
-
return driver.switchToFrame(null);
|
|
32
|
-
},
|
|
33
|
-
parentContext(driver) {
|
|
34
|
-
return driver.switchToParentFrame();
|
|
35
|
-
},
|
|
36
|
-
childContext(driver, reference) {
|
|
37
|
-
return driver.switchToFrame(reference);
|
|
38
|
-
},
|
|
39
|
-
takeScreenshot(driver) {
|
|
40
|
-
return driver.takeScreenshot();
|
|
41
|
-
},
|
|
42
|
-
getDriverInfo(driver) {
|
|
43
|
-
return driver.info;
|
|
44
|
-
},
|
|
45
|
-
async getWindowSize(driver) {
|
|
46
|
-
const rect = await driver.getWindowRect();
|
|
47
|
-
return rect;
|
|
48
|
-
},
|
|
49
|
-
async setWindowSize(driver, size) {
|
|
50
|
-
await driver.setWindowRect(size);
|
|
51
|
-
},
|
|
52
|
-
async getUrl(driver) {
|
|
53
|
-
if (this._isNative)
|
|
54
|
-
return null;
|
|
55
|
-
return driver.getUrl();
|
|
56
|
-
},
|
|
57
|
-
async getTitle(driver) {
|
|
58
|
-
if (this._isNative)
|
|
59
|
-
return null;
|
|
60
|
-
return driver.getTitle();
|
|
61
|
-
},
|
|
62
|
-
async visit(driver, url) {
|
|
63
|
-
await driver.visit(url);
|
|
64
|
-
},
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
65
20
|
};
|
|
66
|
-
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.visit = exports.getTitle = exports.getUrl = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.transformSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
|
|
23
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
24
|
+
function isDriver(driver) {
|
|
25
|
+
return driver && driver.constructor.name === 'MockDriver';
|
|
26
|
+
}
|
|
27
|
+
exports.isDriver = isDriver;
|
|
28
|
+
function isElement(element) {
|
|
29
|
+
return utils.types.has(element, 'id');
|
|
30
|
+
}
|
|
31
|
+
exports.isElement = isElement;
|
|
32
|
+
function isSelector(selector) {
|
|
33
|
+
return utils.types.isString(selector) || utils.types.has(selector, ['using', 'value']);
|
|
34
|
+
}
|
|
35
|
+
exports.isSelector = isSelector;
|
|
36
|
+
function transformSelector(selector) {
|
|
37
|
+
return utils.types.has(selector, 'selector') ? selector.selector : selector;
|
|
38
|
+
}
|
|
39
|
+
exports.transformSelector = transformSelector;
|
|
40
|
+
function isStaleElementError() {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
exports.isStaleElementError = isStaleElementError;
|
|
44
|
+
async function isEqualElements(_driver, element1, element2) {
|
|
45
|
+
return element1.id === element2.id;
|
|
46
|
+
}
|
|
47
|
+
exports.isEqualElements = isEqualElements;
|
|
48
|
+
async function executeScript(driver, script, arg) {
|
|
49
|
+
return driver.executeScript(script, [arg]);
|
|
50
|
+
}
|
|
51
|
+
exports.executeScript = executeScript;
|
|
52
|
+
async function findElement(driver, selector, parent) {
|
|
53
|
+
return driver.findElement(selector, parent);
|
|
54
|
+
}
|
|
55
|
+
exports.findElement = findElement;
|
|
56
|
+
async function findElements(driver, selector, parent) {
|
|
57
|
+
return driver.findElements(selector, parent);
|
|
58
|
+
}
|
|
59
|
+
exports.findElements = findElements;
|
|
60
|
+
async function mainContext(driver) {
|
|
61
|
+
return driver.switchToFrame(null);
|
|
62
|
+
}
|
|
63
|
+
exports.mainContext = mainContext;
|
|
64
|
+
async function parentContext(driver) {
|
|
65
|
+
return driver.switchToParentFrame();
|
|
66
|
+
}
|
|
67
|
+
exports.parentContext = parentContext;
|
|
68
|
+
async function childContext(driver, element) {
|
|
69
|
+
return driver.switchToFrame(element);
|
|
70
|
+
}
|
|
71
|
+
exports.childContext = childContext;
|
|
72
|
+
async function takeScreenshot(driver) {
|
|
73
|
+
return driver.takeScreenshot();
|
|
74
|
+
}
|
|
75
|
+
exports.takeScreenshot = takeScreenshot;
|
|
76
|
+
async function getDriverInfo(driver) {
|
|
77
|
+
return driver.info;
|
|
78
|
+
}
|
|
79
|
+
exports.getDriverInfo = getDriverInfo;
|
|
80
|
+
async function getWindowSize(driver) {
|
|
81
|
+
const rect = await driver.getWindowRect();
|
|
82
|
+
return rect;
|
|
83
|
+
}
|
|
84
|
+
exports.getWindowSize = getWindowSize;
|
|
85
|
+
async function setWindowSize(driver, size) {
|
|
86
|
+
await driver.setWindowRect(size);
|
|
87
|
+
}
|
|
88
|
+
exports.setWindowSize = setWindowSize;
|
|
89
|
+
async function getUrl(driver) {
|
|
90
|
+
if (this._isNative)
|
|
91
|
+
return null;
|
|
92
|
+
return driver.getUrl();
|
|
93
|
+
}
|
|
94
|
+
exports.getUrl = getUrl;
|
|
95
|
+
async function getTitle(driver) {
|
|
96
|
+
if (this._isNative)
|
|
97
|
+
return null;
|
|
98
|
+
return driver.getTitle();
|
|
99
|
+
}
|
|
100
|
+
exports.getTitle = getTitle;
|
|
101
|
+
async function visit(driver, url) {
|
|
102
|
+
await driver.visit(url);
|
|
103
|
+
}
|
|
104
|
+
exports.visit = visit;
|
package/dist/index.js
CHANGED
|
@@ -6,25 +6,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
11
|
};
|
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.fake = void 0;
|
|
26
13
|
__exportStar(require("./driver"), exports);
|
|
27
14
|
__exportStar(require("./context"), exports);
|
|
28
15
|
__exportStar(require("./element"), exports);
|
|
29
|
-
__exportStar(require("./fake/mock-driver"), exports);
|
|
30
|
-
exports.fake = __importStar(require("./fake/spec-driver"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "git://github.com/applitools/eyes.sdk.javascript1.git"
|
|
19
|
+
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
20
|
+
"directory": "packages/driver"
|
|
20
21
|
},
|
|
21
22
|
"license": "SEE LICENSE IN LICENSE",
|
|
22
23
|
"author": {
|
|
@@ -25,16 +26,22 @@
|
|
|
25
26
|
},
|
|
26
27
|
"main": "./dist/index.js",
|
|
27
28
|
"types": "./types/index.d.ts",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"default": "./dist/index.js",
|
|
32
|
+
"types": "./types/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./fake": {
|
|
35
|
+
"default": "./dist/fake/index.js",
|
|
36
|
+
"types": "./types/fake/index.d.ts"
|
|
37
|
+
}
|
|
31
38
|
},
|
|
32
39
|
"files": [
|
|
33
40
|
"dist",
|
|
34
41
|
"types"
|
|
35
42
|
],
|
|
36
43
|
"scripts": {
|
|
37
|
-
"lint": "eslint '**/*.ts'
|
|
44
|
+
"lint": "eslint '**/*.ts'",
|
|
38
45
|
"build": "tsc",
|
|
39
46
|
"test": "mocha --no-timeouts -r ts-node/register ./test/**/*.spec.ts",
|
|
40
47
|
"deps": "bongo deps",
|
|
@@ -49,11 +56,11 @@
|
|
|
49
56
|
},
|
|
50
57
|
"dependencies": {
|
|
51
58
|
"@applitools/snippets": "2.1.7",
|
|
52
|
-
"@applitools/types": "1.0.
|
|
53
|
-
"@applitools/utils": "1.2.
|
|
59
|
+
"@applitools/types": "1.0.20",
|
|
60
|
+
"@applitools/utils": "1.2.4"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
56
|
-
"@applitools/sdk-release-kit": "0.13.
|
|
63
|
+
"@applitools/sdk-release-kit": "0.13.4",
|
|
57
64
|
"@types/mocha": "^9.0.0",
|
|
58
65
|
"@types/node": "^16.3.3",
|
|
59
66
|
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
package/types/context.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare class Context<TDriver, TContext, TElement, TSelector> {
|
|
|
64
64
|
getLocationInMainContext(): Promise<types.Location>;
|
|
65
65
|
getLocationInViewport(): Promise<types.Location>;
|
|
66
66
|
getRegionInViewport(region: types.Region): Promise<types.Region>;
|
|
67
|
+
getCookies(): Promise<types.Cookie[]>;
|
|
67
68
|
private preserveInnerOffset;
|
|
68
69
|
private preserveContextRegions;
|
|
69
70
|
private preserveScrollingRegion;
|
package/types/driver.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
20
20
|
get mainContext(): Context<TDriver, TContext, TElement, TSelector>;
|
|
21
21
|
get features(): {
|
|
22
22
|
shadowSelector?: boolean;
|
|
23
|
+
allCookies?: boolean;
|
|
23
24
|
};
|
|
24
25
|
get deviceName(): string;
|
|
25
26
|
get platformName(): string;
|
|
@@ -54,6 +55,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
54
55
|
setViewportSize(size: types.Size): Promise<void>;
|
|
55
56
|
getDisplaySize(): Promise<types.Size>;
|
|
56
57
|
getOrientation(): Promise<'portrait' | 'landscape'>;
|
|
58
|
+
getCookies(): Promise<types.Cookie[]>;
|
|
57
59
|
getTitle(): Promise<string>;
|
|
58
60
|
getUrl(): Promise<string>;
|
|
59
61
|
visit(url: string): Promise<void>;
|
|
@@ -1,34 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
constructor({ viewport, device, platform, browser, ua }?: {
|
|
4
|
-
viewport?: {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
};
|
|
8
|
-
device: any;
|
|
9
|
-
platform: any;
|
|
10
|
-
browser: any;
|
|
11
|
-
ua: any;
|
|
12
|
-
});
|
|
13
|
-
_device: any;
|
|
14
|
-
_platform: any;
|
|
15
|
-
_browser: any;
|
|
16
|
-
_ua: any;
|
|
17
|
-
_window: {
|
|
18
|
-
title: string;
|
|
19
|
-
url: string;
|
|
20
|
-
rect: {
|
|
21
|
-
width: number;
|
|
22
|
-
height: number;
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
_methods: Map<any, any>;
|
|
28
|
-
_scripts: Map<any, any>;
|
|
29
|
-
_elements: Map<any, any>;
|
|
30
|
-
_contexts: Map<any, any>;
|
|
31
|
-
_contextId: any;
|
|
1
|
+
export declare class MockDriver {
|
|
2
|
+
constructor(options?: {});
|
|
32
3
|
mockScript(scriptMatcher: any, resultGenerator: any): void;
|
|
33
4
|
mockElement(selector: any, state: any): any;
|
|
34
5
|
mockElements(nodes: any, { parentId, parentContextId, parentRootId }?: {
|
|
@@ -51,21 +22,14 @@ export class MockDriver {
|
|
|
51
22
|
executeScript(script: any, args?: any[]): Promise<any>;
|
|
52
23
|
findElement(selector: any, rootElement: any): Promise<any>;
|
|
53
24
|
findElements(selector: any, rootElement: any): Promise<any>;
|
|
54
|
-
switchToFrame(reference: any): Promise<
|
|
55
|
-
switchToParentFrame(): Promise<
|
|
56
|
-
getWindowRect(): Promise<
|
|
57
|
-
width: number;
|
|
58
|
-
height: number;
|
|
59
|
-
x: number;
|
|
60
|
-
y: number;
|
|
61
|
-
}>;
|
|
25
|
+
switchToFrame(reference: any): Promise<this>;
|
|
26
|
+
switchToParentFrame(): Promise<this>;
|
|
27
|
+
getWindowRect(): Promise<any>;
|
|
62
28
|
setWindowRect(rect: any): Promise<void>;
|
|
63
|
-
getUrl(): Promise<
|
|
64
|
-
getTitle(): Promise<
|
|
29
|
+
getUrl(): Promise<any>;
|
|
30
|
+
getTitle(): Promise<any>;
|
|
65
31
|
visit(url: any): Promise<void>;
|
|
66
32
|
takeScreenshot(): Promise<void>;
|
|
67
33
|
toString(): string;
|
|
68
34
|
toJSON(): string;
|
|
69
|
-
[inspect.custom](): string;
|
|
70
35
|
}
|
|
71
|
-
import { inspect } from "util";
|
|
@@ -1,40 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function getWindowSize(driver: any): Promise<any>;
|
|
31
|
-
function getWindowSize(driver: any): Promise<any>;
|
|
32
|
-
function setWindowSize(driver: any, size: any): Promise<void>;
|
|
33
|
-
function setWindowSize(driver: any, size: any): Promise<void>;
|
|
34
|
-
function getUrl(driver: any): Promise<any>;
|
|
35
|
-
function getUrl(driver: any): Promise<any>;
|
|
36
|
-
function getTitle(driver: any): Promise<any>;
|
|
37
|
-
function getTitle(driver: any): Promise<any>;
|
|
38
|
-
function visit(driver: any, url: any): Promise<void>;
|
|
39
|
-
function visit(driver: any, url: any): Promise<void>;
|
|
40
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Size, DriverInfo } from '@applitools/types';
|
|
3
|
+
export declare type Driver = any;
|
|
4
|
+
export declare type Element = any;
|
|
5
|
+
export declare type Selector = string | {
|
|
6
|
+
using: string;
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function isDriver(driver: any): driver is Driver;
|
|
10
|
+
export declare function isElement(element: any): element is Element;
|
|
11
|
+
export declare function isSelector(selector: any): selector is Selector;
|
|
12
|
+
export declare function transformSelector(selector: Selector | {
|
|
13
|
+
selector: Selector;
|
|
14
|
+
}): Selector;
|
|
15
|
+
export declare function isStaleElementError(): boolean;
|
|
16
|
+
export declare function isEqualElements(_driver: Driver, element1: Element, element2: Element): Promise<boolean>;
|
|
17
|
+
export declare function executeScript(driver: Driver, script: ((arg: any) => any) | string, arg: any): Promise<any>;
|
|
18
|
+
export declare function findElement(driver: Driver, selector: Selector, parent?: Element): Promise<Element>;
|
|
19
|
+
export declare function findElements(driver: Driver, selector: Selector, parent?: Element): Promise<Element[]>;
|
|
20
|
+
export declare function mainContext(driver: Driver): Promise<Driver>;
|
|
21
|
+
export declare function parentContext(driver: Driver): Promise<Driver>;
|
|
22
|
+
export declare function childContext(driver: Driver, element: Element): Promise<Driver>;
|
|
23
|
+
export declare function takeScreenshot(driver: Driver): Promise<Buffer | string>;
|
|
24
|
+
export declare function getDriverInfo(driver: Driver): Promise<DriverInfo>;
|
|
25
|
+
export declare function getWindowSize(driver: Driver): Promise<Size>;
|
|
26
|
+
export declare function setWindowSize(driver: Driver, size: Size): Promise<void>;
|
|
27
|
+
export declare function getUrl(driver: Driver): Promise<string>;
|
|
28
|
+
export declare function getTitle(driver: Driver): Promise<string>;
|
|
29
|
+
export declare function visit(driver: Driver, url: string): Promise<void>;
|