@applitools/driver 1.7.1 → 1.8.1
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/README.md +2 -2
- package/dist/capabilities.js +17 -7
- package/dist/driver.js +11 -3
- package/package.json +3 -3
- package/types/capabilities.d.ts +1 -1
- package/types/driver.d.ts +2 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ The API and abstractions of the interface provides an extra functionality which
|
|
|
46
46
|
- [spec.type(context, element, value)](#spectypecontext-element-value)
|
|
47
47
|
- [spec.visit(driver, url)](#specvisitdriver-url)
|
|
48
48
|
- [spec.getOrientation(driver)](#specgetorientationdriver)
|
|
49
|
-
- [spec.
|
|
49
|
+
- [spec.getBarsSize(driver)](#specgetbarsSizedriver)
|
|
50
50
|
- [spec.getElementRegion(driver, element)](#specgetelementregiondriver-element)
|
|
51
51
|
- [spec.getElementAttribute(driver, element, attribute)](#specgetelementattributedriver-element-attribute)
|
|
52
52
|
- [spec.getElementText(driver, element)](#specgetelementtextdriver-element)
|
|
@@ -433,7 +433,7 @@ This command is optional.
|
|
|
433
433
|
### spec.getOrientation(driver)
|
|
434
434
|
TBD
|
|
435
435
|
|
|
436
|
-
### spec.
|
|
436
|
+
### spec.getBarsSize(driver)
|
|
437
437
|
TBD
|
|
438
438
|
|
|
439
439
|
### spec.getElementRegion(driver, element)
|
package/dist/capabilities.js
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseCapabilities = void 0;
|
|
4
|
-
function parseCapabilities(capabilities) {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4
|
+
function parseCapabilities(capabilities, customConfig) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
6
6
|
if (capabilities.capabilities)
|
|
7
7
|
capabilities = capabilities.capabilities;
|
|
8
|
+
if (!(customConfig === null || customConfig === void 0 ? void 0 : customConfig.keepPlatformNameAsIs)) {
|
|
9
|
+
// We use `startsWith` for just a theorerical reason. It's not based on any concrete case that we knew of at the time of writing this code.
|
|
10
|
+
if ((_a = capabilities.platformName) === null || _a === void 0 ? void 0 : _a.startsWith('android')) {
|
|
11
|
+
capabilities.platformName = capabilities.platformName.charAt(0).toUpperCase() + capabilities.platformName.slice(1);
|
|
12
|
+
}
|
|
13
|
+
// We use `startsWith` for just a theorerical reason. It's not based on any concrete case that we knew of at the time of writing this code.
|
|
14
|
+
if ((_b = capabilities.platformName) === null || _b === void 0 ? void 0 : _b.startsWith('ios')) {
|
|
15
|
+
capabilities.platformName = 'iOS' + capabilities.platformName.slice(3);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
const info = {
|
|
9
19
|
browserName: !capabilities.app && !capabilities.bundleId
|
|
10
|
-
? ((
|
|
20
|
+
? ((_c = capabilities.browserName) !== null && _c !== void 0 ? _c : (_d = capabilities.desired) === null || _d === void 0 ? void 0 : _d.browserName) || undefined
|
|
11
21
|
: undefined,
|
|
12
|
-
browserVersion: ((
|
|
13
|
-
platformName: ((
|
|
22
|
+
browserVersion: ((_e = capabilities.browserVersion) !== null && _e !== void 0 ? _e : capabilities.version) || undefined,
|
|
23
|
+
platformName: ((_g = (_f = capabilities.platformName) !== null && _f !== void 0 ? _f : capabilities.platform) !== null && _g !== void 0 ? _g : (_h = capabilities.desired) === null || _h === void 0 ? void 0 : _h.platformName) || undefined,
|
|
14
24
|
platformVersion: capabilities.platformVersion || undefined,
|
|
15
25
|
isW3C: isW3C(capabilities),
|
|
16
26
|
isMobile: isMobile(capabilities),
|
|
17
27
|
};
|
|
18
28
|
if (info.isMobile) {
|
|
19
|
-
info.deviceName = ((
|
|
29
|
+
info.deviceName = ((_k = (_j = capabilities.desired) === null || _j === void 0 ? void 0 : _j.deviceName) !== null && _k !== void 0 ? _k : capabilities.deviceName) || undefined;
|
|
20
30
|
info.isNative = info.isMobile && !info.browserName;
|
|
21
31
|
info.isIOS = isIOS(capabilities);
|
|
22
32
|
info.isAndroid = isAndroid(capabilities);
|
|
23
|
-
info.orientation = (
|
|
33
|
+
info.orientation = (_m = ((_l = capabilities.deviceOrientation) !== null && _l !== void 0 ? _l : capabilities.orientation)) === null || _m === void 0 ? void 0 : _m.toLowerCase();
|
|
24
34
|
}
|
|
25
35
|
if (info.isNative) {
|
|
26
36
|
info.pixelRatio = capabilities.pixelRatio;
|
package/dist/driver.js
CHANGED
|
@@ -144,7 +144,7 @@ class Driver {
|
|
|
144
144
|
var _w, _x, _y, _z, _0, _1, _2, _3;
|
|
145
145
|
const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
|
|
146
146
|
this._logger.log('Driver capabilities', capabilities);
|
|
147
|
-
const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities) : undefined;
|
|
147
|
+
const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities, this._customConfig) : undefined;
|
|
148
148
|
const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
|
|
149
149
|
this._driverInfo = Object.assign(Object.assign({}, capabilitiesInfo), driverInfo);
|
|
150
150
|
if (this.isWeb) {
|
|
@@ -168,15 +168,17 @@ class Driver {
|
|
|
168
168
|
(_q = (_2 = this._driverInfo.features).allCookies) !== null && _q !== void 0 ? _q : (_2.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
|
-
const barsHeight = await ((_s = (_r = this._spec).
|
|
171
|
+
const barsHeight = await ((_s = (_r = this._spec).getBarsSize) === null || _s === void 0 ? void 0 : _s.call(_r, this.target).catch(() => undefined));
|
|
172
172
|
const displaySize = await this.getDisplaySize();
|
|
173
173
|
// calculate status and navigation bars sizes
|
|
174
174
|
if (barsHeight) {
|
|
175
|
+
const orientation = await this.getOrientation();
|
|
175
176
|
// when status bar is overlapping content on android it returns status bar height equal to viewport height
|
|
176
177
|
if (this.isAndroid && barsHeight.statusBarHeight / this.pixelRatio < displaySize.height) {
|
|
177
178
|
this._driverInfo.statusBarHeight = Math.max((_t = this._driverInfo.statusBarHeight) !== null && _t !== void 0 ? _t : 0, barsHeight.statusBarHeight);
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
+
// android witches the width and height only for the navigationBar in landscape mode.
|
|
181
|
+
this._driverInfo.navigationBarHeight = Math.max((_u = this._driverInfo.navigationBarHeight) !== null && _u !== void 0 ? _u : 0, orientation === 'landscape' ? barsHeight.navigationBarWidth : barsHeight.navigationBarHeight);
|
|
180
182
|
}
|
|
181
183
|
if (this.isAndroid) {
|
|
182
184
|
this._driverInfo.statusBarHeight /= this.pixelRatio;
|
|
@@ -499,6 +501,12 @@ class Driver {
|
|
|
499
501
|
this._logger.log('Extracted device orientation:', orientation);
|
|
500
502
|
return orientation;
|
|
501
503
|
}
|
|
504
|
+
async setOrientation(orientation) {
|
|
505
|
+
if (this.isWeb && !this.isMobile)
|
|
506
|
+
return;
|
|
507
|
+
await this._spec.setOrientation(this.target, orientation);
|
|
508
|
+
this._logger.log('set device orientation:', orientation);
|
|
509
|
+
}
|
|
502
510
|
async getCookies() {
|
|
503
511
|
var _a, _b, _c;
|
|
504
512
|
if (this.isNative || !this.features.allCookies)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@applitools/snippets": "2.2.3",
|
|
77
|
-
"@applitools/types": "1.
|
|
77
|
+
"@applitools/types": "1.4.0",
|
|
78
78
|
"@applitools/utils": "1.2.14"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@applitools/bongo": "^2.0.3",
|
|
82
|
-
"@types/mocha": "^9.
|
|
82
|
+
"@types/mocha": "^9.1.1",
|
|
83
83
|
"@types/node": "^16.3.3",
|
|
84
84
|
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
|
85
85
|
"@typescript-eslint/parser": "^4.28.3",
|
package/types/capabilities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as types from '@applitools/types';
|
|
2
2
|
declare type Capabilities = Record<string, any>;
|
|
3
|
-
export declare function parseCapabilities(capabilities: Capabilities): types.DriverInfo;
|
|
3
|
+
export declare function parseCapabilities(capabilities: Capabilities, customConfig?: types.CustomCapabilitiesConfig): types.DriverInfo;
|
|
4
4
|
export {};
|
package/types/driver.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
17
17
|
spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
18
18
|
driver: Driver<TDriver, TContext, TElement, TSelector> | TDriver;
|
|
19
19
|
logger?: any;
|
|
20
|
-
customConfig?:
|
|
20
|
+
customConfig?: types.CustomDriverConfig;
|
|
21
21
|
});
|
|
22
22
|
get target(): TDriver;
|
|
23
23
|
get currentContext(): Context<TDriver, TContext, TElement, TSelector>;
|
|
@@ -62,6 +62,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
62
62
|
setViewportSize(size: types.Size): Promise<void>;
|
|
63
63
|
getDisplaySize(): Promise<types.Size>;
|
|
64
64
|
getOrientation(): Promise<'portrait' | 'landscape'>;
|
|
65
|
+
setOrientation(orientation: types.ScreenOrientation): Promise<void>;
|
|
65
66
|
getCookies(): Promise<types.Cookie[]>;
|
|
66
67
|
getTitle(): Promise<string>;
|
|
67
68
|
getUrl(): Promise<string>;
|