@applitools/driver 1.9.16 → 1.9.17
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/element.js +55 -35
- package/package.json +1 -1
package/dist/element.js
CHANGED
|
@@ -90,8 +90,8 @@ class Element {
|
|
|
90
90
|
}
|
|
91
91
|
async contains(innerElement) {
|
|
92
92
|
const contains = await this.withRefresh(async () => {
|
|
93
|
-
var _a, _b, _c, _d;
|
|
94
|
-
var
|
|
93
|
+
var _a, _b, _c, _d, _e;
|
|
94
|
+
var _f;
|
|
95
95
|
innerElement = innerElement instanceof Element ? innerElement.target : innerElement;
|
|
96
96
|
if (this.driver.isWeb) {
|
|
97
97
|
this._logger.log('Checking if web element with selector', this.selector, 'contains element', innerElement);
|
|
@@ -105,25 +105,34 @@ class Element {
|
|
|
105
105
|
if (await this.equals(innerElement))
|
|
106
106
|
return false;
|
|
107
107
|
// if the inner element region is contained in this element region, then it then could be assumed that the inner element is contained in this element
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
:
|
|
108
|
+
let contentRegion = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getContentRegion(this));
|
|
109
|
+
if (!contentRegion || !this.driver.isAndroid) {
|
|
110
|
+
const nativeContentRegion = await this.getAttribute('contentSize')
|
|
111
|
+
.then(data => {
|
|
112
|
+
const contentSize = JSON.parse(data);
|
|
113
|
+
return {
|
|
114
|
+
x: contentSize.left,
|
|
115
|
+
y: contentSize.top,
|
|
116
|
+
width: contentSize.width,
|
|
117
|
+
height: this.driver.isIOS
|
|
118
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
119
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
.catch(err => {
|
|
123
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
124
|
+
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
125
|
+
});
|
|
126
|
+
contentRegion = {
|
|
127
|
+
x: nativeContentRegion.x,
|
|
128
|
+
y: nativeContentRegion.y,
|
|
129
|
+
width: Math.max((_c = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.width) !== null && _c !== void 0 ? _c : 0, nativeContentRegion.width),
|
|
130
|
+
height: Math.max((_d = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.height) !== null && _d !== void 0 ? _d : 0, nativeContentRegion.height),
|
|
118
131
|
};
|
|
119
|
-
}
|
|
120
|
-
.catch(err => {
|
|
121
|
-
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
122
|
-
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
123
|
-
}));
|
|
132
|
+
}
|
|
124
133
|
const innerRegion = await this._spec.getElementRegion(this.driver.target, innerElement);
|
|
125
134
|
const contains = utils.geometry.contains(contentRegion, innerRegion);
|
|
126
|
-
(
|
|
135
|
+
(_e = (_f = this._state).containedElements) !== null && _e !== void 0 ? _e : (_f.containedElements = new Map());
|
|
127
136
|
this._state.containedElements.set(innerElement, contains);
|
|
128
137
|
return contains;
|
|
129
138
|
}
|
|
@@ -182,7 +191,7 @@ class Element {
|
|
|
182
191
|
if (this._state.contentSize)
|
|
183
192
|
return this._state.contentSize;
|
|
184
193
|
const size = await this.withRefresh(async () => {
|
|
185
|
-
var _a, _b;
|
|
194
|
+
var _a, _b, _c;
|
|
186
195
|
if (this.driver.isWeb) {
|
|
187
196
|
this._logger.log('Extracting content size of web element with selector', this.selector);
|
|
188
197
|
return this.context.execute(snippets.getElementContentSize, [this]);
|
|
@@ -190,23 +199,34 @@ class Element {
|
|
|
190
199
|
else {
|
|
191
200
|
this._logger.log('Extracting content size of native element with selector', this.selector);
|
|
192
201
|
try {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
: contentSize.
|
|
202
|
+
let contentRegion = await ((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.getContentRegion(this));
|
|
203
|
+
this._logger.log('Extracted native content region using helper library', contentRegion);
|
|
204
|
+
// on android extraction of this argument will perform non-deterministic touch action, so it is better to avoid it
|
|
205
|
+
if (!contentRegion || !this.driver.isAndroid) {
|
|
206
|
+
const attrContentRegion = await this.getAttribute('contentSize')
|
|
207
|
+
.then(data => {
|
|
208
|
+
const contentSize = JSON.parse(data);
|
|
209
|
+
return {
|
|
210
|
+
x: contentSize.left,
|
|
211
|
+
y: contentSize.top,
|
|
212
|
+
width: contentSize.width,
|
|
213
|
+
height: this.driver.isIOS
|
|
214
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
215
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
216
|
+
};
|
|
217
|
+
})
|
|
218
|
+
.catch(err => {
|
|
219
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
220
|
+
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
221
|
+
});
|
|
222
|
+
this._logger.log('Extracted native content region using attribute', attrContentRegion);
|
|
223
|
+
contentRegion = {
|
|
224
|
+
x: attrContentRegion.x,
|
|
225
|
+
y: attrContentRegion.y,
|
|
226
|
+
width: Math.max((_b = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.width) !== null && _b !== void 0 ? _b : 0, attrContentRegion.width),
|
|
227
|
+
height: Math.max((_c = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.height) !== null && _c !== void 0 ? _c : 0, attrContentRegion.height),
|
|
203
228
|
};
|
|
204
|
-
}
|
|
205
|
-
.catch(err => {
|
|
206
|
-
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
207
|
-
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
208
|
-
}));
|
|
209
|
-
this._logger.log('Extracted native content region', contentRegion);
|
|
229
|
+
}
|
|
210
230
|
this._state.contentSize = utils.geometry.size(contentRegion);
|
|
211
231
|
if (this.driver.isAndroid) {
|
|
212
232
|
this._state.contentSize = utils.geometry.scale(this._state.contentSize, 1 / this.driver.pixelRatio);
|