@applitools/driver 1.5.0 → 1.5.3
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 +17 -1
- package/dist/context.js +10 -5
- package/dist/element.js +14 -5
- package/package.json +3 -3
- package/types/element.d.ts +1 -0
- package/types/spec-utils.d.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## 1.5.3 - 2022/3/12
|
|
7
|
+
|
|
8
|
+
- when handling shadowRoot, send the element containing the doc frage and the root itself to element constructor
|
|
9
|
+
- change the sensible default value for touchPadding when running on Android to 20 (from 24)
|
|
10
|
+
- add error logging in element.ts when unable to complete a getAttribute lookup
|
|
11
|
+
- updated to @applitools/snippets@2.2.1 (from 2.2.0)
|
|
12
|
+
- updated to @applitools/types@1.2.1 (from 1.2.0)
|
|
13
|
+
|
|
14
|
+
## 1.5.2 - 2022/3/7
|
|
15
|
+
|
|
16
|
+
- exclude iOS Safari from dynamic SRE calculation
|
|
17
|
+
|
|
18
|
+
## 1.5.1 - 2022/3/7
|
|
19
|
+
|
|
20
|
+
- fix `getScrollingElement` in mobile native
|
|
21
|
+
|
|
6
22
|
## 1.5.0 - 2022/3/6
|
|
7
23
|
|
|
8
24
|
- add `waitForSelector` method
|
|
@@ -228,4 +244,4 @@
|
|
|
228
244
|
|
|
229
245
|
## 1.0.0 - 2020/12/1
|
|
230
246
|
|
|
231
|
-
- Provide a framework-agnostic way to work with webdriver/cdp drivers
|
|
247
|
+
- Provide a framework-agnostic way to work with webdriver/cdp drivers
|
package/dist/context.js
CHANGED
|
@@ -214,10 +214,11 @@ class Context {
|
|
|
214
214
|
if ((_a = this.driver.features) === null || _a === void 0 ? void 0 : _a.shadowSelector)
|
|
215
215
|
return { context, selector: elementSelector };
|
|
216
216
|
let root = null;
|
|
217
|
+
let element = null;
|
|
217
218
|
let currentSelector = elementSelector;
|
|
218
219
|
while (specUtils.isCommonSelector(this._spec, currentSelector) &&
|
|
219
220
|
specUtils.isSelector(this._spec, currentSelector.shadow)) {
|
|
220
|
-
|
|
221
|
+
element = await this._spec.findElement(this.target, specUtils.transformSelector(this._spec, currentSelector, this.driver), root);
|
|
221
222
|
if (!element)
|
|
222
223
|
return null;
|
|
223
224
|
root = await this._spec.executeScript(this.target, snippets.getShadowRoot, [element]);
|
|
@@ -227,7 +228,7 @@ class Context {
|
|
|
227
228
|
}
|
|
228
229
|
return {
|
|
229
230
|
context,
|
|
230
|
-
shadow: root ? new element_1.Element({ spec: this._spec, context, element
|
|
231
|
+
shadow: root ? new element_1.Element({ spec: this._spec, context, element, logger: this._logger, root }) : null,
|
|
231
232
|
selector: currentSelector,
|
|
232
233
|
};
|
|
233
234
|
}
|
|
@@ -352,10 +353,14 @@ class Context {
|
|
|
352
353
|
if (this._scrollingElement) {
|
|
353
354
|
this._scrollingElement = await this.element(this._scrollingElement);
|
|
354
355
|
}
|
|
356
|
+
else if (this.driver.isWeb) {
|
|
357
|
+
const isIOS = this.driver.isIOS;
|
|
358
|
+
const selector = isIOS ? 'html' : await this.execute(snippets.getDocumentScrollingElement);
|
|
359
|
+
this._logger.log(`default SRE is ${selector}${isIOS ? ' (because Safari on iOS)' : ''}`);
|
|
360
|
+
this._scrollingElement = await this.element({ type: 'css', selector });
|
|
361
|
+
}
|
|
355
362
|
else {
|
|
356
|
-
|
|
357
|
-
this._logger.log(`default SRE is ${selector}`);
|
|
358
|
-
this._scrollingElement = await this.element(this.driver.isWeb ? { type: 'css', selector } : { type: 'xpath', selector: '//*[@scrollable="true"]' });
|
|
363
|
+
this._scrollingElement = await this.element({ type: 'xpath', selector: '//*[@scrollable="true"]' });
|
|
359
364
|
}
|
|
360
365
|
}
|
|
361
366
|
return this._scrollingElement;
|
package/dist/element.js
CHANGED
|
@@ -46,9 +46,13 @@ class Element {
|
|
|
46
46
|
if (options.logger)
|
|
47
47
|
this._logger = options.logger;
|
|
48
48
|
if (this._spec.isElement(options.element)) {
|
|
49
|
-
|
|
49
|
+
let elementToUse = options.element;
|
|
50
|
+
if (options.root) {
|
|
51
|
+
elementToUse = options.root;
|
|
52
|
+
}
|
|
53
|
+
this._target = (_c = (_b = (_a = this._spec).transformElement) === null || _b === void 0 ? void 0 : _b.call(_a, elementToUse)) !== null && _c !== void 0 ? _c : elementToUse;
|
|
50
54
|
// Some frameworks contains information about the selector inside an element
|
|
51
|
-
this._selector = (_d = options.selector) !== null && _d !== void 0 ? _d : (_f = (_e = this._spec).extractSelector) === null || _f === void 0 ? void 0 : _f.call(_e,
|
|
55
|
+
this._selector = (_d = options.selector) !== null && _d !== void 0 ? _d : (_f = (_e = this._spec).extractSelector) === null || _f === void 0 ? void 0 : _f.call(_e, elementToUse);
|
|
52
56
|
this._index = options.index;
|
|
53
57
|
}
|
|
54
58
|
else if (specUtils.isSelector(this._spec, options.selector)) {
|
|
@@ -151,7 +155,8 @@ class Element {
|
|
|
151
155
|
height: (this.driver.isAndroid ? contentSize.height : 0) + contentSize.scrollableOffset,
|
|
152
156
|
};
|
|
153
157
|
})
|
|
154
|
-
.catch(
|
|
158
|
+
.catch(err => {
|
|
159
|
+
this._logger.log(`Unable to get the attribute 'contentSize' when looking up touchPadding due to the following error:`, `'${err.message}'`);
|
|
155
160
|
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
156
161
|
}), { touchPadding } = _d, contentRegion = __rest(_d, ["touchPadding"]);
|
|
157
162
|
this._logger.log('Extracted native content size attribute', contentRegion);
|
|
@@ -162,6 +167,7 @@ class Element {
|
|
|
162
167
|
height: Math.max((_c = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _c !== void 0 ? _c : 0, contentRegion.height),
|
|
163
168
|
};
|
|
164
169
|
this._touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : this._touchPadding;
|
|
170
|
+
this._logger.log('touchPadding', this._touchPadding);
|
|
165
171
|
if (this.driver.isAndroid) {
|
|
166
172
|
this._state.contentSize = utils.geometry.scale(this._state.contentSize, 1 / this.driver.pixelRatio);
|
|
167
173
|
}
|
|
@@ -228,8 +234,11 @@ class Element {
|
|
|
228
234
|
else if (this.driver.isAndroid) {
|
|
229
235
|
const data = await this.getAttribute('contentSize')
|
|
230
236
|
.then(JSON.parse)
|
|
231
|
-
.catch(
|
|
232
|
-
|
|
237
|
+
.catch(err => {
|
|
238
|
+
this._logger.log(`Unable to get the attribute 'contentSize' when looking up touchPadding due to the following error:`, `'${err.message}'`);
|
|
239
|
+
});
|
|
240
|
+
this._touchPadding = (_a = data === null || data === void 0 ? void 0 : data.touchPadding) !== null && _a !== void 0 ? _a : 20;
|
|
241
|
+
this._logger.log('touchPadding', this._touchPadding);
|
|
233
242
|
}
|
|
234
243
|
}
|
|
235
244
|
return this._touchPadding;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@applitools/snippets": "2.2.
|
|
77
|
-
"@applitools/types": "1.2.
|
|
76
|
+
"@applitools/snippets": "2.2.1",
|
|
77
|
+
"@applitools/types": "1.2.1",
|
|
78
78
|
"@applitools/utils": "1.2.13"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/types/element.d.ts
CHANGED
package/types/spec-utils.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type * as types from '@applitools/types';
|
|
2
|
-
|
|
2
|
+
declare type CommonSelector<TSelector = never> = {
|
|
3
|
+
selector: TSelector | string;
|
|
4
|
+
type?: string;
|
|
5
|
+
shadow?: CommonSelector<TSelector> | TSelector | string;
|
|
6
|
+
frame?: CommonSelector<TSelector> | TSelector | string;
|
|
7
|
+
};
|
|
8
|
+
export declare function isCommonSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is CommonSelector<TSelector>;
|
|
3
9
|
export declare function isSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is types.Selector<TSelector>;
|
|
4
10
|
export declare function transformSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector' | 'transformSelector'>, selector: types.Selector<TSelector>, environment?: {
|
|
5
11
|
isWeb?: boolean;
|
|
@@ -11,3 +17,4 @@ export declare function splitSelector<TSelector>(spec: Pick<types.SpecDriver<unk
|
|
|
11
17
|
contextSelectors: types.Selector<TSelector>[];
|
|
12
18
|
elementSelector: types.Selector<TSelector>;
|
|
13
19
|
};
|
|
20
|
+
export {};
|