@applitools/driver 1.11.37 → 1.11.39
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/dist/capabilities.js +34 -27
- package/dist/context.js +15 -9
- package/dist/driver.js +396 -430
- package/dist/element.js +68 -44
- package/dist/fake/mock-driver.js +9 -12
- package/dist/fake/spec-driver.js +1 -1
- package/dist/user-agent.js +53 -12
- package/package.json +3 -3
- package/types/capabilities.d.ts +3 -4
- package/types/driver.d.ts +35 -51
- package/types/fake/mock-driver.d.ts +1 -1
- package/types/fake/spec-driver.d.ts +1 -1
- package/types/spec-driver.d.ts +3 -39
- package/types/types.d.ts +61 -0
- package/types/user-agent.d.ts +2 -12
- package/dist/user-agent-data.js +0 -33
- package/types/user-agent-data.d.ts +0 -13
package/dist/capabilities.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
3
|
+
exports.extractCapabilitiesViewport = exports.extractCapabilitiesEnvironment = void 0;
|
|
4
|
+
function extractCapabilitiesEnvironment(capabilities) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6
6
|
if (capabilities.capabilities)
|
|
7
7
|
capabilities = capabilities.capabilities;
|
|
8
|
-
const
|
|
8
|
+
const environment = {
|
|
9
9
|
browserName: !capabilities.app && !capabilities.bundleId
|
|
10
10
|
? ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined
|
|
11
11
|
: undefined,
|
|
@@ -17,36 +17,43 @@ function parseCapabilities(capabilities) {
|
|
|
17
17
|
isChrome: isChrome(capabilities),
|
|
18
18
|
isECClient: Boolean(capabilities['applitools:isECClient']),
|
|
19
19
|
};
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
info.isNative = true;
|
|
20
|
+
if (environment === null || environment === void 0 ? void 0 : environment.isMobile) {
|
|
21
|
+
environment.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
|
|
22
|
+
environment.isIOS = isIOS(capabilities);
|
|
23
|
+
environment.isAndroid = isAndroid(capabilities);
|
|
24
|
+
if (!environment.browserName) {
|
|
25
|
+
environment.isNative = true;
|
|
27
26
|
}
|
|
28
|
-
else if (
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
else if (environment.isIOS && !/mobilesafari/i.test(capabilities.CFBundleIdentifier)) {
|
|
28
|
+
environment.browserName = undefined;
|
|
29
|
+
environment.isNative = true;
|
|
31
30
|
}
|
|
32
31
|
else {
|
|
33
|
-
|
|
32
|
+
environment.isNative = false;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
return environment;
|
|
36
|
+
}
|
|
37
|
+
exports.extractCapabilitiesEnvironment = extractCapabilitiesEnvironment;
|
|
38
|
+
function extractCapabilitiesViewport(capabilities) {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
if (capabilities.capabilities)
|
|
41
|
+
capabilities = capabilities.capabilities;
|
|
42
|
+
const viewport = {
|
|
43
|
+
displaySize: extractDisplaySize(capabilities),
|
|
44
|
+
orientation: (_b = ((_a = capabilities.deviceOrientation) !== null && _a !== void 0 ? _a : capabilities.orientation)) === null || _b === void 0 ? void 0 : _b.toLowerCase(),
|
|
45
|
+
pixelRatio: capabilities.pixelRatio,
|
|
46
|
+
statusBarSize: (_c = capabilities.statBarHeight) !== null && _c !== void 0 ? _c : (_d = capabilities.viewportRect) === null || _d === void 0 ? void 0 : _d.top,
|
|
47
|
+
};
|
|
48
|
+
if (viewport.displaySize && viewport.orientation && capabilities.viewportRect) {
|
|
49
|
+
viewport.navigationBarSize =
|
|
50
|
+
viewport.orientation === 'landscape'
|
|
51
|
+
? viewport.displaySize.width - (capabilities.viewportRect.left + capabilities.viewportRect.width)
|
|
52
|
+
: viewport.displaySize.height - (capabilities.viewportRect.top + capabilities.viewportRect.height);
|
|
46
53
|
}
|
|
47
|
-
return
|
|
54
|
+
return viewport;
|
|
48
55
|
}
|
|
49
|
-
exports.
|
|
56
|
+
exports.extractCapabilitiesViewport = extractCapabilitiesViewport;
|
|
50
57
|
function isW3C(capabilities) {
|
|
51
58
|
const isW3C = Boolean((capabilities.platformName || capabilities.browserVersion) &&
|
|
52
59
|
(capabilities.platformVersion || capabilities.hasOwnProperty('setWindowRect')));
|
package/dist/context.js
CHANGED
|
@@ -101,11 +101,12 @@ class Context {
|
|
|
101
101
|
var _a;
|
|
102
102
|
await this.focus();
|
|
103
103
|
const { parent, all, wait } = options;
|
|
104
|
-
const
|
|
104
|
+
const environment = await this.driver.getEnvironment();
|
|
105
|
+
const transformedSelector = specUtils.transformSelector(this._spec, selector, environment);
|
|
105
106
|
let elements = [];
|
|
106
107
|
if (wait) {
|
|
107
108
|
if (this._spec.waitForSelector) {
|
|
108
|
-
const element = await this._spec.waitForSelector(this.target, specUtils.transformSelector(this._spec, selector,
|
|
109
|
+
const element = await this._spec.waitForSelector(this.target, specUtils.transformSelector(this._spec, selector, environment), parent, wait);
|
|
109
110
|
if (element)
|
|
110
111
|
elements = [element];
|
|
111
112
|
}
|
|
@@ -113,7 +114,7 @@ class Context {
|
|
|
113
114
|
let waiting = true;
|
|
114
115
|
const timeout = setTimeout(() => (waiting = false), wait.timeout);
|
|
115
116
|
while (waiting) {
|
|
116
|
-
const element = await this._spec.findElement(this.target, specUtils.transformSelector(this._spec, selector,
|
|
117
|
+
const element = await this._spec.findElement(this.target, specUtils.transformSelector(this._spec, selector, environment), parent);
|
|
117
118
|
if (element) {
|
|
118
119
|
clearTimeout(timeout);
|
|
119
120
|
elements = [element];
|
|
@@ -393,12 +394,13 @@ class Context {
|
|
|
393
394
|
async getScrollingElement() {
|
|
394
395
|
if (!(this._scrollingElement instanceof element_1.Element)) {
|
|
395
396
|
await this.focus();
|
|
397
|
+
const environment = await this.driver.getEnvironment();
|
|
396
398
|
if (this._scrollingElement) {
|
|
397
399
|
this._scrollingElement = await this.element(this._scrollingElement);
|
|
398
400
|
}
|
|
399
|
-
else if (
|
|
401
|
+
else if (environment.isWeb) {
|
|
400
402
|
let selector;
|
|
401
|
-
if (
|
|
403
|
+
if (environment.isIOS && !environment.isEmulation) {
|
|
402
404
|
selector = 'html';
|
|
403
405
|
this._logger.log(`Using hardcoded default scrolling element for Safari on iOS - "${selector}"`);
|
|
404
406
|
}
|
|
@@ -518,12 +520,13 @@ class Context {
|
|
|
518
520
|
else
|
|
519
521
|
region = { x: 0, y: 0, width: Infinity, height: Infinity };
|
|
520
522
|
let currentContext = this;
|
|
523
|
+
const environment = await this.driver.getEnvironment();
|
|
521
524
|
while (currentContext) {
|
|
522
525
|
const contextRegion = await currentContext.getClientRegion();
|
|
523
526
|
// const contextScrollingRegion = await currentContext.getScrollingRegion()
|
|
524
527
|
const parentContextInnerOffset = (_b = (await ((_a = currentContext.parent) === null || _a === void 0 ? void 0 : _a.getInnerOffset()))) !== null && _b !== void 0 ? _b : { x: 0, y: 0 };
|
|
525
528
|
// TODO revisit
|
|
526
|
-
if (
|
|
529
|
+
if (environment.isWeb ||
|
|
527
530
|
(!utils.geometry.equals(contextRegion, region) && utils.geometry.contains(contextRegion, region))) {
|
|
528
531
|
this._logger.log('Intersecting context region', contextRegion, 'with context region', region);
|
|
529
532
|
region = utils.geometry.intersect(contextRegion, utils.geometry.offset(region, contextRegion));
|
|
@@ -535,11 +538,14 @@ class Context {
|
|
|
535
538
|
return region;
|
|
536
539
|
}
|
|
537
540
|
async getCookies() {
|
|
538
|
-
var _a, _b
|
|
539
|
-
|
|
541
|
+
var _a, _b;
|
|
542
|
+
const environment = await this.driver.getEnvironment();
|
|
543
|
+
if (!environment.isWeb)
|
|
540
544
|
return [];
|
|
541
545
|
await this.focus();
|
|
542
|
-
|
|
546
|
+
const cookies = await ((_b = (_a = this._spec).getCookies) === null || _b === void 0 ? void 0 : _b.call(_a, this.target, true));
|
|
547
|
+
this._logger.log('Extracted context cookies', cookies);
|
|
548
|
+
return cookies !== null && cookies !== void 0 ? cookies : [];
|
|
543
549
|
}
|
|
544
550
|
async preserveInnerOffset() {
|
|
545
551
|
this._state.innerOffset = await this.getInnerOffset();
|