@applitools/driver 1.6.1 → 1.7.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/README.md +2 -2
- package/dist/driver.js +18 -4
- package/package.json +5 -5
- package/types/driver.d.ts +3 -0
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/driver.js
CHANGED
|
@@ -35,6 +35,7 @@ class Driver {
|
|
|
35
35
|
if (options.driver instanceof Driver)
|
|
36
36
|
return options.driver;
|
|
37
37
|
this._spec = options.spec;
|
|
38
|
+
this._customConfig = options.customConfig || {};
|
|
38
39
|
if (options.logger)
|
|
39
40
|
this._logger = options.logger;
|
|
40
41
|
if (this._spec.isDriver(options.driver)) {
|
|
@@ -167,15 +168,17 @@ class Driver {
|
|
|
167
168
|
(_q = (_2 = this._driverInfo.features).allCookies) !== null && _q !== void 0 ? _q : (_2.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
|
|
168
169
|
}
|
|
169
170
|
else {
|
|
170
|
-
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));
|
|
171
172
|
const displaySize = await this.getDisplaySize();
|
|
172
173
|
// calculate status and navigation bars sizes
|
|
173
174
|
if (barsHeight) {
|
|
175
|
+
const orientation = await this.getOrientation();
|
|
174
176
|
// when status bar is overlapping content on android it returns status bar height equal to viewport height
|
|
175
177
|
if (this.isAndroid && barsHeight.statusBarHeight / this.pixelRatio < displaySize.height) {
|
|
176
178
|
this._driverInfo.statusBarHeight = Math.max((_t = this._driverInfo.statusBarHeight) !== null && _t !== void 0 ? _t : 0, barsHeight.statusBarHeight);
|
|
177
179
|
}
|
|
178
|
-
|
|
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);
|
|
179
182
|
}
|
|
180
183
|
if (this.isAndroid) {
|
|
181
184
|
this._driverInfo.statusBarHeight /= this.pixelRatio;
|
|
@@ -419,7 +422,6 @@ class Driver {
|
|
|
419
422
|
var _a;
|
|
420
423
|
let size;
|
|
421
424
|
if (this.isNative) {
|
|
422
|
-
this._logger.log('Extracting viewport size from native driver');
|
|
423
425
|
if ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.viewportSize) {
|
|
424
426
|
size = this._driverInfo.viewportSize;
|
|
425
427
|
}
|
|
@@ -432,7 +434,13 @@ class Driver {
|
|
|
432
434
|
}
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
|
-
|
|
437
|
+
if (this._customConfig.useCeilForViewportSize) {
|
|
438
|
+
size = utils.geometry.ceil(size);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
size = utils.geometry.round(size);
|
|
442
|
+
}
|
|
443
|
+
this._logger.log(`Extracting viewport size from native driver using '${this._customConfig.useCeilForViewportSize ? 'ceil' : 'round'}' method`);
|
|
436
444
|
}
|
|
437
445
|
else if (this._spec.getViewportSize) {
|
|
438
446
|
this._logger.log('Extracting viewport size from web driver using spec method');
|
|
@@ -493,6 +501,12 @@ class Driver {
|
|
|
493
501
|
this._logger.log('Extracted device orientation:', orientation);
|
|
494
502
|
return orientation;
|
|
495
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
|
+
}
|
|
496
510
|
async getCookies() {
|
|
497
511
|
var _a, _b, _c;
|
|
498
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.7.2",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@applitools/snippets": "2.2.
|
|
77
|
-
"@applitools/types": "1.3.
|
|
78
|
-
"@applitools/utils": "1.2.
|
|
76
|
+
"@applitools/snippets": "2.2.3",
|
|
77
|
+
"@applitools/types": "1.3.2",
|
|
78
|
+
"@applitools/utils": "1.2.14"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@applitools/bongo": "^2.0.
|
|
81
|
+
"@applitools/bongo": "^2.0.3",
|
|
82
82
|
"@types/mocha": "^9.0.0",
|
|
83
83
|
"@types/node": "^16.3.3",
|
|
84
84
|
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
package/types/driver.d.ts
CHANGED
|
@@ -10,12 +10,14 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
10
10
|
private _currentContext;
|
|
11
11
|
private _driverInfo;
|
|
12
12
|
private _logger;
|
|
13
|
+
private _customConfig;
|
|
13
14
|
private _helper?;
|
|
14
15
|
protected readonly _spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
15
16
|
constructor(options: {
|
|
16
17
|
spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
17
18
|
driver: Driver<TDriver, TContext, TElement, TSelector> | TDriver;
|
|
18
19
|
logger?: any;
|
|
20
|
+
customConfig?: any;
|
|
19
21
|
});
|
|
20
22
|
get target(): TDriver;
|
|
21
23
|
get currentContext(): Context<TDriver, TContext, TElement, TSelector>;
|
|
@@ -60,6 +62,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
60
62
|
setViewportSize(size: types.Size): Promise<void>;
|
|
61
63
|
getDisplaySize(): Promise<types.Size>;
|
|
62
64
|
getOrientation(): Promise<'portrait' | 'landscape'>;
|
|
65
|
+
setOrientation(orientation: types.ScreenOrientation): Promise<void>;
|
|
63
66
|
getCookies(): Promise<types.Cookie[]>;
|
|
64
67
|
getTitle(): Promise<string>;
|
|
65
68
|
getUrl(): Promise<string>;
|