@applitools/eyes-testcafe 2.0.0-beta.9 → 2.0.0
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 +467 -0
- package/LICENSE +1 -1
- package/README.md +7 -531
- package/dist/api.js +51 -0
- package/dist/extract-environment.js +15 -0
- package/dist/index-legacy.js +5 -0
- package/dist/index.js +19 -0
- package/dist/legacy.js +225 -0
- package/dist/spec-driver.js +245 -0
- package/package.json +73 -77
- package/types/index-legacy.d.ts +2 -0
- package/types/index.d.ts +1833 -0
- package/dist/captureFrameAndPoll.js +0 -1468
- package/dist/captureFrameAndPollForIE.js +0 -12569
- package/index.js +0 -30
- package/lib/BordersAwareElementContentLocationProvider.js +0 -79
- package/lib/Eyes.js +0 -927
- package/lib/EyesFactory.js +0 -73
- package/lib/EyesTestCafe.js +0 -1277
- package/lib/EyesTestcafeUtils.js +0 -440
- package/lib/EyesVisualGrid.js +0 -345
- package/lib/ImageOrientationHandler.js +0 -31
- package/lib/JavascriptHandler.js +0 -20
- package/lib/TestCafeExecutor.js +0 -57
- package/lib/capture/EyesWebDriverScreenshot.js +0 -650
- package/lib/capture/EyesWebDriverScreenshotFactory.js +0 -32
- package/lib/capture/FirefoxScreenshotImageProvider.js +0 -63
- package/lib/capture/ImageProviderFactory.js +0 -38
- package/lib/capture/SafariScreenshotImageProvider.js +0 -254
- package/lib/capture/TakesScreenshotImageProvider.js +0 -35
- package/lib/errors/EyesDriverOperationError.js +0 -10
- package/lib/errors/NoFramesError.js +0 -7
- package/lib/fluent/AccessibilityRegionByElement.js +0 -46
- package/lib/fluent/AccessibilityRegionBySelector.js +0 -58
- package/lib/fluent/FloatingRegionByElement.js +0 -56
- package/lib/fluent/FloatingRegionBySelector.js +0 -63
- package/lib/fluent/FrameLocator.js +0 -110
- package/lib/fluent/IgnoreRegionByElement.js +0 -51
- package/lib/fluent/IgnoreRegionBySelector.js +0 -57
- package/lib/fluent/SelectorByElement.js +0 -37
- package/lib/fluent/SelectorByLocator.js +0 -47
- package/lib/fluent/Target.js +0 -17
- package/lib/fluent/TestcafeCheckSettings.js +0 -352
- package/lib/frames/Frame.js +0 -149
- package/lib/frames/FrameChain.js +0 -175
- package/lib/getCaptureDomScript.js +0 -14
- package/lib/hash.js +0 -15
- package/lib/isTestcafeSelector.js +0 -7
- package/lib/makeClientFunctionWrapper.js +0 -61
- package/lib/positioning/CssTranslatePositionMemento.js +0 -39
- package/lib/positioning/CssTranslatePositionProvider.js +0 -130
- package/lib/positioning/ElementPositionMemento.js +0 -36
- package/lib/positioning/ElementPositionProvider.js +0 -88
- package/lib/positioning/FirefoxRegionPositionCompensation.js +0 -45
- package/lib/positioning/ImageRotation.js +0 -22
- package/lib/positioning/OverflowAwareCssTranslatePositionProvider.js +0 -17
- package/lib/positioning/OverflowAwareScrollPositionProvider.js +0 -17
- package/lib/positioning/RegionPositionCompensationFactory.js +0 -37
- package/lib/positioning/SafariRegionPositionCompensation.js +0 -26
- package/lib/positioning/ScrollPositionMemento.js +0 -36
- package/lib/positioning/ScrollPositionProvider.js +0 -118
- package/lib/positioning/fixImageMarkPosition.js +0 -36
- package/lib/regionVisibility/MoveToRegionVisibilityStrategy.js +0 -55
- package/lib/regionVisibility/NopRegionVisibilityStrategy.js +0 -35
- package/lib/regionVisibility/RegionVisibilityStrategy.js +0 -30
- package/lib/runner/ClassicRunner.js +0 -49
- package/lib/runner/EyesRunner.js +0 -41
- package/lib/runner/TestResultContainer.js +0 -38
- package/lib/runner/TestResultsSummary.js +0 -112
- package/lib/runner/VisualGridRunner.js +0 -57
- package/lib/safeExecuteFunction.js +0 -28
- package/lib/wrappers/EyesTargetLocator.js +0 -335
- package/lib/wrappers/EyesWebDriver.js +0 -571
- package/lib/wrappers/EyesWebElement.js +0 -383
- package/lib/wrappers/EyesWebElementPromise.js +0 -68
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {Selector} = require('testcafe')
|
|
4
|
-
const {
|
|
5
|
-
Region,
|
|
6
|
-
ArgumentGuard,
|
|
7
|
-
CoordinatesType,
|
|
8
|
-
// TypeUtils,
|
|
9
|
-
RectangleSize,
|
|
10
|
-
Location,
|
|
11
|
-
EyesError,
|
|
12
|
-
GeneralUtils,
|
|
13
|
-
} = require('@applitools/eyes-common')
|
|
14
|
-
// const {MouseTrigger} = require('@applitools/eyes-sdk-core')
|
|
15
|
-
|
|
16
|
-
const JS_GET_SCROLL_SIZE = 'return [arguments[0].scrollWidth, arguments[0].scrollHeight];'
|
|
17
|
-
|
|
18
|
-
const JS_GET_CLIENT_SIZE = 'return [arguments[0].clientWidth, arguments[0].clientHeight];'
|
|
19
|
-
|
|
20
|
-
const JS_GET_COMPUTED_STYLE_FN =
|
|
21
|
-
'function getCmpStyle(el, p) { return window.getComputedStyle ? window.getComputedStyle(el, null).getPropertyValue(p) : (el.currentStyle ? el.currentStyle[p] : null); };'
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @param {string} styleProp
|
|
25
|
-
* @return {string}
|
|
26
|
-
*/
|
|
27
|
-
const JS_GET_COMPUTED_STYLE_FORMATTED_STR = styleProp =>
|
|
28
|
-
`${JS_GET_COMPUTED_STYLE_FN}return getCmpStyle(arguments[0], '${styleProp}');`
|
|
29
|
-
|
|
30
|
-
const JS_GET_SCROLL_LOCATION = 'return [arguments[0].scrollLeft, arguments[0].scrollTop];'
|
|
31
|
-
|
|
32
|
-
const JS_GET_OVERFLOW = 'return arguments[0].style.overflow;'
|
|
33
|
-
|
|
34
|
-
const JS_GET_BORDER_WIDTHS_ARR =
|
|
35
|
-
'var retVal = retVal || [];' +
|
|
36
|
-
'if (window.getComputedStyle) { ' +
|
|
37
|
-
'var computedStyle = window.getComputedStyle(elem, null);' +
|
|
38
|
-
'retVal.push(computedStyle.getPropertyValue("border-left-width"));' +
|
|
39
|
-
'retVal.push(computedStyle.getPropertyValue("border-top-width"));' +
|
|
40
|
-
'retVal.push(computedStyle.getPropertyValue("border-right-width")); ' +
|
|
41
|
-
'retVal.push(computedStyle.getPropertyValue("border-bottom-width"));' +
|
|
42
|
-
'} else if (elem.currentStyle) { ' +
|
|
43
|
-
'retVal.push(elem.currentStyle["border-left-width"]);' +
|
|
44
|
-
'retVal.push(elem.currentStyle["border-top-width"]);' +
|
|
45
|
-
'retVal.push(elem.currentStyle["border-right-width"]);' +
|
|
46
|
-
'retVal.push(elem.currentStyle["border-bottom-width"]);' +
|
|
47
|
-
'} else { ' +
|
|
48
|
-
'retVal.push(0,0,0,0);' +
|
|
49
|
-
'}'
|
|
50
|
-
|
|
51
|
-
const JS_GET_SIZE_AND_BORDER_WIDTHS = `${'var elem = arguments[0]; ' +
|
|
52
|
-
'var retVal = [elem.clientWidth, elem.clientHeight]; '}${JS_GET_BORDER_WIDTHS_ARR}return retVal;`
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Wraps a Testcafe Web Element.
|
|
56
|
-
*/
|
|
57
|
-
class EyesWebElement {
|
|
58
|
-
/**
|
|
59
|
-
* @param {Logger} logger
|
|
60
|
-
* @param {EyesWebDriver} eyesDriver
|
|
61
|
-
* @param {WebElement} webElement
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
constructor(logger, eyesDriver, webElement) {
|
|
65
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
66
|
-
ArgumentGuard.notNull(eyesDriver, 'eyesDriver')
|
|
67
|
-
ArgumentGuard.notNull(webElement, 'webElement')
|
|
68
|
-
|
|
69
|
-
if (webElement instanceof EyesWebElement) {
|
|
70
|
-
return webElement
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this._logger = logger
|
|
74
|
-
this._eyesDriver = eyesDriver
|
|
75
|
-
|
|
76
|
-
/** @type {PositionProvider} */
|
|
77
|
-
this._positionProvider = undefined
|
|
78
|
-
this._webElement = webElement
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param {object} obj
|
|
83
|
-
* @return {boolean}
|
|
84
|
-
*/
|
|
85
|
-
static isLocator(obj) {
|
|
86
|
-
return !!obj && obj.addCustomMethods && obj.find && obj.parent
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Compares two WebElements for equality.
|
|
91
|
-
*
|
|
92
|
-
* @param {!EyesWebElement|WebElement} a A WebElement.
|
|
93
|
-
* @param {!EyesWebElement|WebElement} b A WebElement.
|
|
94
|
-
* @return {!Promise<boolean>} - A promise that will be resolved to whether the two WebElements are equal.
|
|
95
|
-
*/
|
|
96
|
-
static async equals(_a, _b) {
|
|
97
|
-
// TODO (amit)
|
|
98
|
-
return false
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @override
|
|
103
|
-
*/
|
|
104
|
-
toString() {
|
|
105
|
-
return GeneralUtils.toString(this, ['_logger', '_eyesDriver', '_positionProvider'])
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @return {Promise<Region>}
|
|
110
|
-
*/
|
|
111
|
-
async getBounds() {
|
|
112
|
-
const rect = await this.getRect()
|
|
113
|
-
let {x: left, y: top, width, height} = rect
|
|
114
|
-
|
|
115
|
-
if (left < 0) {
|
|
116
|
-
width = Math.max(0, width + left)
|
|
117
|
-
left = 0
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (top < 0) {
|
|
121
|
-
height = Math.max(0, height + top)
|
|
122
|
-
top = 0
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return new Region(left, top, width, height, CoordinatesType.CONTEXT_RELATIVE)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Returns the computed value of the style property for the current element.
|
|
130
|
-
*
|
|
131
|
-
* @param {string} propStyle - The style property which value we would like to extract.
|
|
132
|
-
* @return {Promise<string>} - The value of the style property of the element, or {@code null}.
|
|
133
|
-
*/
|
|
134
|
-
getComputedStyle(propStyle) {
|
|
135
|
-
return this.executeScript(JS_GET_COMPUTED_STYLE_FORMATTED_STR(propStyle))
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @param {string} propStyle - The style property which value we would like to extract.
|
|
140
|
-
* @return {Promise<number>} - The integer value of a computed style.
|
|
141
|
-
*/
|
|
142
|
-
async getComputedStyleInteger(propStyle) {
|
|
143
|
-
const result = await this.getComputedStyle(propStyle)
|
|
144
|
-
return Math.round(parseFloat(result.trim().replace('px', '')))
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// noinspection JSUnusedGlobalSymbols
|
|
148
|
-
/**
|
|
149
|
-
* @deprecated use {@link getScrollLocation} instead
|
|
150
|
-
* @return {Promise<number>} - The value of the scrollLeft property of the element.
|
|
151
|
-
*/
|
|
152
|
-
async getScrollLeft() {
|
|
153
|
-
const result = await this.executeScript(JS_GET_SCROLL_LOCATION)
|
|
154
|
-
return Math.ceil(result[0]) || 0
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// noinspection JSUnusedGlobalSymbols
|
|
158
|
-
/**
|
|
159
|
-
* @deprecated use {@link getScrollLocation} instead
|
|
160
|
-
* @return {Promise<number>} - The value of the scrollTop property of the element.
|
|
161
|
-
*/
|
|
162
|
-
async getScrollTop() {
|
|
163
|
-
const result = await this.executeScript(JS_GET_SCROLL_LOCATION)
|
|
164
|
-
return Math.ceil(result[1]) || 0
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @return {Promise<Location>} - The value of the `scrollLeft` and `scrollTop` property of the element.
|
|
169
|
-
*/
|
|
170
|
-
async getScrollLocation() {
|
|
171
|
-
const result = await this.executeScript(JS_GET_SCROLL_LOCATION)
|
|
172
|
-
return new Location(Math.ceil(result[0]) || 0, Math.ceil(result[1]) || 0)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// noinspection JSUnusedGlobalSymbols
|
|
176
|
-
/**
|
|
177
|
-
* @deprecated use {@link getScrollSize} instead
|
|
178
|
-
* @return {Promise<number>} - The value of the scrollWidth property of the element.
|
|
179
|
-
*/
|
|
180
|
-
async getScrollWidth() {
|
|
181
|
-
const result = await this.executeScript(JS_GET_SCROLL_SIZE)
|
|
182
|
-
return Math.ceil(result[0]) || 0
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// noinspection JSUnusedGlobalSymbols
|
|
186
|
-
/**
|
|
187
|
-
* @deprecated use {@link getScrollSize} instead
|
|
188
|
-
* @return {Promise<number>} - The value of the scrollHeight property of the element.
|
|
189
|
-
*/
|
|
190
|
-
async getScrollHeight() {
|
|
191
|
-
const result = await this.executeScript(JS_GET_SCROLL_SIZE)
|
|
192
|
-
return Math.ceil(result[1]) || 0
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @return {Promise<RectangleSize>} - The value of the `scrollWidth` and `scrollHeight` property of the element.
|
|
197
|
-
*/
|
|
198
|
-
async getScrollSize() {
|
|
199
|
-
const result = await this.executeScript(JS_GET_SCROLL_SIZE)
|
|
200
|
-
return new RectangleSize(Math.ceil(result[0]) || 0, Math.ceil(result[1]) || 0)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// noinspection JSUnusedGlobalSymbols
|
|
204
|
-
/**
|
|
205
|
-
* @deprecated use {@link getClientSize} instead
|
|
206
|
-
* @return {Promise<number>}
|
|
207
|
-
*/
|
|
208
|
-
async getClientWidth() {
|
|
209
|
-
const result = await this.executeScript(JS_GET_CLIENT_SIZE)
|
|
210
|
-
return Math.ceil(result[0]) || 0
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// noinspection JSUnusedGlobalSymbols
|
|
214
|
-
/**
|
|
215
|
-
* @deprecated use {@link getClientSize} instead
|
|
216
|
-
* @return {Promise<number>}
|
|
217
|
-
*/
|
|
218
|
-
async getClientHeight() {
|
|
219
|
-
const result = await this.executeScript(JS_GET_CLIENT_SIZE)
|
|
220
|
-
return Math.ceil(result[1]) || 0
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @return {Promise<RectangleSize>} - The value of the `clientWidth` and `clientHeight` property of the element.
|
|
225
|
-
*/
|
|
226
|
-
async getClientSize() {
|
|
227
|
-
const result = await this.executeScript(JS_GET_CLIENT_SIZE)
|
|
228
|
-
return new RectangleSize(Math.ceil(result[0]) || 0, Math.ceil(result[1]) || 0)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// noinspection JSUnusedGlobalSymbols
|
|
232
|
-
/**
|
|
233
|
-
* @return {Promise<number>} - The width of the left border.
|
|
234
|
-
*/
|
|
235
|
-
getBorderLeftWidth() {
|
|
236
|
-
return this.getComputedStyleInteger('border-left-width')
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// noinspection JSUnusedGlobalSymbols
|
|
240
|
-
/**
|
|
241
|
-
* @return {Promise<number>} - The width of the right border.
|
|
242
|
-
*/
|
|
243
|
-
getBorderRightWidth() {
|
|
244
|
-
return this.getComputedStyleInteger('border-right-width')
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// noinspection JSUnusedGlobalSymbols
|
|
248
|
-
/**
|
|
249
|
-
* @return {Promise<number>} - The width of the top border.
|
|
250
|
-
*/
|
|
251
|
-
getBorderTopWidth() {
|
|
252
|
-
return this.getComputedStyleInteger('border-top-width')
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// noinspection JSUnusedGlobalSymbols
|
|
256
|
-
/**
|
|
257
|
-
* @return {Promise<number>} - The width of the bottom border.
|
|
258
|
-
*/
|
|
259
|
-
getBorderBottomWidth() {
|
|
260
|
-
return this.getComputedStyleInteger('border-bottom-width')
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* @return {Promise<{top: number, left: number, bottom: number, width: number, right: number, height: number}>}
|
|
265
|
-
*/
|
|
266
|
-
async getSizeAndBorders() {
|
|
267
|
-
const result = await this.executeScript(JS_GET_SIZE_AND_BORDER_WIDTHS)
|
|
268
|
-
return {
|
|
269
|
-
width: Math.ceil(result[0]),
|
|
270
|
-
height: Math.ceil(result[1]),
|
|
271
|
-
left: Math.ceil(result[2].replace('px', '')),
|
|
272
|
-
top: Math.ceil(result[2].replace('px', '')),
|
|
273
|
-
right: Math.ceil(result[3].replace('px', '')),
|
|
274
|
-
bottom: Math.ceil(result[5].replace('px', '')),
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Scrolls to the specified location inside the element.
|
|
280
|
-
*
|
|
281
|
-
* @param {Location} location - The location to scroll to.
|
|
282
|
-
* @return {Promise<Location>} - the current location after scroll.
|
|
283
|
-
*/
|
|
284
|
-
scrollTo(location) {
|
|
285
|
-
try {
|
|
286
|
-
const script = `
|
|
287
|
-
if (arguments[0] === document.documentElement && window.scrollTo) {
|
|
288
|
-
window.scrollTo(${location.getX()}, ${location.getY()});
|
|
289
|
-
} else {
|
|
290
|
-
arguments[0].scrollLeft=${location.getX()}; arguments[0].scrollTop=${location.getY()};
|
|
291
|
-
}
|
|
292
|
-
return [arguments[0].scrollLeft, arguments[0].scrollTop];
|
|
293
|
-
`
|
|
294
|
-
|
|
295
|
-
const position = this.executeScript(script)
|
|
296
|
-
return new Location(Math.ceil(position[0]) || 0, Math.ceil(position[1]) || 0)
|
|
297
|
-
} catch (err) {
|
|
298
|
-
throw EyesError('Could not get scroll position!', err)
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @return {Promise<string>} - The overflow of the element.
|
|
304
|
-
*/
|
|
305
|
-
getOverflow() {
|
|
306
|
-
return this.executeScript(JS_GET_OVERFLOW)
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* @param {string} overflow - The overflow to set
|
|
311
|
-
* @return {Promise} - The overflow of the element.
|
|
312
|
-
*/
|
|
313
|
-
setOverflow(overflow) {
|
|
314
|
-
return this.executeScript(`arguments[0].style.overflow = '${overflow}'`)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @param {string} script - The script to execute with the element as last parameter
|
|
319
|
-
* @return {Promise<*>} - The result returned from the script
|
|
320
|
-
*/
|
|
321
|
-
executeScript(script) {
|
|
322
|
-
// noinspection JSValidateTypes
|
|
323
|
-
return this._eyesDriver.executeScript(script, this._webElement)
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// noinspection JSCheckFunctionSignatures
|
|
327
|
-
/**
|
|
328
|
-
* @inheritDoc
|
|
329
|
-
* @return {!EyesWebElement} A WebElement that can be used to issue commands against the located element.
|
|
330
|
-
* If the element is not found, the element will be invalidated and all scheduled commands aborted.
|
|
331
|
-
*/
|
|
332
|
-
findElement(locator) {
|
|
333
|
-
// TODO (amit): i don't know if this works or when it's needed
|
|
334
|
-
return Selector(locator).then(
|
|
335
|
-
element => new EyesWebElement(this._logger, this._eyesDriver, element),
|
|
336
|
-
)
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* @inheritDoc
|
|
341
|
-
* @return {!Promise<!Array<!EyesWebElement>>} A promise that will resolve to an array of WebElements.
|
|
342
|
-
*/
|
|
343
|
-
findElements(locator) {
|
|
344
|
-
// TODO (amit): i don't know when this is needed
|
|
345
|
-
return super
|
|
346
|
-
.findElements(locator)
|
|
347
|
-
.then(elements =>
|
|
348
|
-
elements.map(element => new EyesWebElement(this._logger, this._eyesDriver, element)),
|
|
349
|
-
)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* @inheritDoc
|
|
354
|
-
* @return {Promise<{width: number, x: number, y: number, height: number}>}
|
|
355
|
-
*/
|
|
356
|
-
async getRect() {
|
|
357
|
-
// The workaround is similar to Java one, but in js we always get raw data with decimal value which we should round up.
|
|
358
|
-
const rect = await this._webElement.boundingClientRect
|
|
359
|
-
const width = Math.ceil(rect.width) || 0
|
|
360
|
-
// noinspection JSSuspiciousNameCombination
|
|
361
|
-
const height = Math.ceil(rect.height) || 0
|
|
362
|
-
const x = Math.ceil(rect.x) || 0
|
|
363
|
-
// noinspection JSSuspiciousNameCombination
|
|
364
|
-
const y = Math.ceil(rect.y) || 0
|
|
365
|
-
return {width, height, x, y}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* @return {PositionProvider}
|
|
370
|
-
*/
|
|
371
|
-
getPositionProvider() {
|
|
372
|
-
return this._positionProvider
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* @param {PositionProvider} positionProvider
|
|
377
|
-
*/
|
|
378
|
-
setPositionProvider(positionProvider) {
|
|
379
|
-
this._positionProvider = positionProvider
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
exports.EyesWebElement = EyesWebElement
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {EyesWebElement} = require('./EyesWebElement')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* EyesWebElementPromise is a promise that will be fulfilled with a WebElement.
|
|
7
|
-
* This serves as a forward proxy on WebElement, allowing calls to be scheduled without directly on this instance
|
|
8
|
-
* before the underlying WebElement has been fulfilled. In other words, the following two statements are equivalent:
|
|
9
|
-
*
|
|
10
|
-
* driver.findElement({id: 'my-button'}).click();
|
|
11
|
-
* driver.findElement({id: 'my-button'}).then(function(el) {
|
|
12
|
-
* return el.click();
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* @final
|
|
16
|
-
* @ignore
|
|
17
|
-
*/
|
|
18
|
-
class EyesWebElementPromise extends EyesWebElement {
|
|
19
|
-
/**
|
|
20
|
-
* @param {Logger} logger
|
|
21
|
-
* @param {EyesWebDriver} driver The parent WebDriver instance for this element.
|
|
22
|
-
* @param {WebElement} webElement A promise that will resolve to the promised element.
|
|
23
|
-
* @param {*} locator
|
|
24
|
-
*/
|
|
25
|
-
constructor(logger, driver, webElement, locator) {
|
|
26
|
-
const wrapper = webElement.then(element => new EyesWebElement(logger, driver, element))
|
|
27
|
-
|
|
28
|
-
super(logger, driver, webElement)
|
|
29
|
-
|
|
30
|
-
this._foundBy = String(locator)
|
|
31
|
-
|
|
32
|
-
// noinspection JSUnresolvedVariable
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
this.then = wrapper.then.bind(wrapper)
|
|
37
|
-
|
|
38
|
-
// noinspection JSUnresolvedVariable
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
this.catch = wrapper.catch.bind(wrapper)
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Defers returning the element ID until the wrapped WebElement has been resolved.
|
|
46
|
-
* @override
|
|
47
|
-
*/
|
|
48
|
-
this.getId = () => webElement.getId()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @override
|
|
53
|
-
*/
|
|
54
|
-
toJSON() {
|
|
55
|
-
return {
|
|
56
|
-
foundBy: this._foundBy,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @override
|
|
62
|
-
*/
|
|
63
|
-
toString() {
|
|
64
|
-
return `[EyesWebElementPromise] -> ${this._foundBy}`
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exports.EyesWebElementPromise = EyesWebElementPromise
|