@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
package/lib/frames/Frame.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ArgumentGuard} = require('@applitools/eyes-common')
|
|
4
|
-
const {ScrollPositionMemento} = require('../positioning/ScrollPositionMemento')
|
|
5
|
-
const {ScrollPositionProvider} = require('../positioning/ScrollPositionProvider')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Encapsulates a frame/iframe. This is a generic type class, and it's actual type is determined by the reference used
|
|
9
|
-
* by the user in order to switch into the frame.
|
|
10
|
-
*/
|
|
11
|
-
class Frame {
|
|
12
|
-
/**
|
|
13
|
-
* @param {Logger} logger - A Logger instance.
|
|
14
|
-
* @param {WebElement} reference - The web element for the frame, used as a reference to switch into the frame.
|
|
15
|
-
* @param {Location} location - The location of the frame within the current frame.
|
|
16
|
-
* @param {RectangleSize} outerSize - The frame element size (i.e., the size of the frame on the screen, not the
|
|
17
|
-
* internal document size).
|
|
18
|
-
* @param {RectangleSize} innerSize - The frame element inner size (i.e., the size of the frame actual size, without
|
|
19
|
-
* borders).
|
|
20
|
-
* @param {Location} originalLocation - The scroll location of the frame.
|
|
21
|
-
* @param {string} jsExecutor - The Javascript Executor to use. Usually that will be the WebDriver.
|
|
22
|
-
*/
|
|
23
|
-
constructor(logger, reference, location, outerSize, innerSize, originalLocation, jsExecutor) {
|
|
24
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
25
|
-
ArgumentGuard.notNull(reference, 'reference')
|
|
26
|
-
ArgumentGuard.notNull(location, 'location')
|
|
27
|
-
ArgumentGuard.notNull(outerSize, 'outerSize')
|
|
28
|
-
ArgumentGuard.notNull(innerSize, 'innerSize')
|
|
29
|
-
ArgumentGuard.notNull(originalLocation, 'originalLocation')
|
|
30
|
-
ArgumentGuard.notNull(jsExecutor, 'jsExecutor')
|
|
31
|
-
|
|
32
|
-
logger.verbose(
|
|
33
|
-
`Frame(logger, reference, ${location}, ${outerSize}, ${innerSize}, ${originalLocation})`,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
this._logger = logger
|
|
37
|
-
this._reference = reference
|
|
38
|
-
this._location = location
|
|
39
|
-
this._outerSize = outerSize
|
|
40
|
-
this._innerSize = innerSize
|
|
41
|
-
this._originalLocation = originalLocation
|
|
42
|
-
this._positionMemento = new ScrollPositionMemento(originalLocation)
|
|
43
|
-
this._jsExecutor = jsExecutor
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @return {WebElement}
|
|
48
|
-
*/
|
|
49
|
-
getReference() {
|
|
50
|
-
return this._reference
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @return {Location}
|
|
55
|
-
*/
|
|
56
|
-
getLocation() {
|
|
57
|
-
return this._location
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @return {RectangleSize}
|
|
62
|
-
*/
|
|
63
|
-
getOuterSize() {
|
|
64
|
-
return this._outerSize
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @return {RectangleSize}
|
|
69
|
-
*/
|
|
70
|
-
getInnerSize() {
|
|
71
|
-
return this._innerSize
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @return {Location}
|
|
76
|
-
*/
|
|
77
|
-
getOriginalLocation() {
|
|
78
|
-
return this._originalLocation
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @return {WebElement}
|
|
83
|
-
*/
|
|
84
|
-
getScrollRootElement() {
|
|
85
|
-
return this._scrollRootElement
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @param {EyesWebDriver} driver
|
|
90
|
-
* @return {Promise<WebElement>}
|
|
91
|
-
*/
|
|
92
|
-
async getForceScrollRootElement(driver) {
|
|
93
|
-
if (!this._scrollRootElement) {
|
|
94
|
-
this._logger.verbose('no scroll root element. selecting default.')
|
|
95
|
-
this._scrollRootElement = await driver.findElement('html')
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return this._scrollRootElement
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {WebElement} scrollRootElement
|
|
103
|
-
*/
|
|
104
|
-
setScrollRootElement(scrollRootElement) {
|
|
105
|
-
this._scrollRootElement = scrollRootElement
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @param {EyesWebDriver} driver
|
|
110
|
-
* @return {Promise}
|
|
111
|
-
*/
|
|
112
|
-
async hideScrollbars(driver) {
|
|
113
|
-
const scrollRootElement = await this.getForceScrollRootElement(driver)
|
|
114
|
-
this._logger.verbose('hiding scrollbars of element:', scrollRootElement)
|
|
115
|
-
this._originalOverflow = await this._jsExecutor.executeScript(
|
|
116
|
-
"var origOF = arguments[0].style.overflow; arguments[0].style.overflow='hidden'; return origOF;",
|
|
117
|
-
scrollRootElement,
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @param {EyesWebDriver} driver
|
|
123
|
-
* @return {Promise}
|
|
124
|
-
*/
|
|
125
|
-
async returnToOriginalOverflow(driver) {
|
|
126
|
-
const scrollRootElement = await this.getForceScrollRootElement(driver)
|
|
127
|
-
this._logger.verbose('returning overflow of element to its original value:', scrollRootElement)
|
|
128
|
-
await this._jsExecutor.executeScript(
|
|
129
|
-
`arguments[0].style.overflow='${this._originalOverflow}';`,
|
|
130
|
-
scrollRootElement,
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @param {EyesWebDriver} driver
|
|
136
|
-
* @return {Promise}
|
|
137
|
-
*/
|
|
138
|
-
async returnToOriginalPosition(driver) {
|
|
139
|
-
const scrollRootElement = await this.getForceScrollRootElement(driver)
|
|
140
|
-
const positionProvider = new ScrollPositionProvider(
|
|
141
|
-
this._logger,
|
|
142
|
-
this._jsExecutor,
|
|
143
|
-
scrollRootElement,
|
|
144
|
-
)
|
|
145
|
-
await positionProvider.restoreState(this._positionMemento)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
exports.Frame = Frame
|
package/lib/frames/FrameChain.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ArgumentGuard, Location} = require('@applitools/eyes-common')
|
|
4
|
-
|
|
5
|
-
const {NoFramesError} = require('../errors/NoFramesError')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @implements {Iterable<Frame>}
|
|
9
|
-
*/
|
|
10
|
-
class FrameChain {
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new frame chain.
|
|
13
|
-
*
|
|
14
|
-
* @param {Logger} logger - A Logger instance.
|
|
15
|
-
* @param {FrameChain} [other] - A frame chain from which the current frame chain will be created.
|
|
16
|
-
*/
|
|
17
|
-
constructor(logger, other) {
|
|
18
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
19
|
-
|
|
20
|
-
this._logger = logger
|
|
21
|
-
this._frames = []
|
|
22
|
-
|
|
23
|
-
if (other) {
|
|
24
|
-
this._frames = other.getFrames().slice(0)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Compares two frame chains.
|
|
30
|
-
*
|
|
31
|
-
* @param {FrameChain} c1 - Frame chain to be compared against c2.
|
|
32
|
-
* @param {FrameChain} c2 - Frame chain to be compared against c1.
|
|
33
|
-
* @return {boolean} - True if both frame chains represent the same frame, false otherwise.
|
|
34
|
-
*/
|
|
35
|
-
static isSameFrameChain(c1, c2) {
|
|
36
|
-
const lc1 = c1.size()
|
|
37
|
-
const lc2 = c2.size()
|
|
38
|
-
|
|
39
|
-
// different chains size means different frames
|
|
40
|
-
if (lc1 !== lc2) {
|
|
41
|
-
return false
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < lc1; i += 1) {
|
|
45
|
-
if (c1.getFrame(i).getReference() !== c2.getFrame(i).getReference()) {
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return true
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @return {number} - The number of frames in the chain.
|
|
55
|
-
*/
|
|
56
|
-
size() {
|
|
57
|
-
return this._frames.length
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Removes all current frames in the frame chain.
|
|
62
|
-
*/
|
|
63
|
-
clear() {
|
|
64
|
-
this._frames = []
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Removes the last inserted frame element. Practically means we switched back to the parent of the current frame
|
|
69
|
-
*
|
|
70
|
-
* @return {Frame}
|
|
71
|
-
*/
|
|
72
|
-
pop() {
|
|
73
|
-
return this._frames.pop()
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @return {?Frame} - Returns the top frame in the chain.
|
|
78
|
-
*/
|
|
79
|
-
peek() {
|
|
80
|
-
if (this._frames.length === 0) {
|
|
81
|
-
return null
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return this._frames[this._frames.length - 1]
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Appends a frame to the frame chain.
|
|
89
|
-
*
|
|
90
|
-
* @param {Frame} frame - The frame to be added.
|
|
91
|
-
*/
|
|
92
|
-
push(frame) {
|
|
93
|
-
return this._frames.push(frame)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @return {Location} - The location of the current frame in the page.
|
|
98
|
-
*/
|
|
99
|
-
getCurrentFrameOffset() {
|
|
100
|
-
let result = new Location(Location.ZERO)
|
|
101
|
-
|
|
102
|
-
this._frames.forEach(frame => {
|
|
103
|
-
result = result.offsetByLocation(frame.getLocation())
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
return result
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @return {Location} - The outermost frame's location, or NoFramesException.
|
|
111
|
-
*/
|
|
112
|
-
getDefaultContentScrollPosition() {
|
|
113
|
-
if (this._frames.length === 0) {
|
|
114
|
-
throw new NoFramesError('No frames in frame chain')
|
|
115
|
-
}
|
|
116
|
-
return new Location(this._frames[0].getOriginalLocation())
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// noinspection JSUnusedGlobalSymbols
|
|
120
|
-
/**
|
|
121
|
-
* @return {RectangleSize} - The size of the current frame.
|
|
122
|
-
*/
|
|
123
|
-
getCurrentFrameSize() {
|
|
124
|
-
this._logger.verbose('getCurrentFrameSize()')
|
|
125
|
-
const result = this._frames[this._frames.length - 1].getOuterSize()
|
|
126
|
-
this._logger.verbose('Done!')
|
|
127
|
-
return result
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @return {RectangleSize} - The inner size of the current frame.
|
|
132
|
-
*/
|
|
133
|
-
getCurrentFrameInnerSize() {
|
|
134
|
-
this._logger.verbose('getCurrentFrameInnerSize()')
|
|
135
|
-
const result = this._frames[this._frames.length - 1].getInnerSize()
|
|
136
|
-
this._logger.verbose('Done!')
|
|
137
|
-
return result
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @return {IterableIterator<Frame>} iterator to go over the frames in the chain.
|
|
142
|
-
*/
|
|
143
|
-
[Symbol.iterator]() {
|
|
144
|
-
// noinspection JSValidateTypes
|
|
145
|
-
return this._frames[Symbol.iterator]()
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @return {Frame[]} - All frames stored in chain
|
|
150
|
-
*/
|
|
151
|
-
getFrames() {
|
|
152
|
-
return this._frames
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @param {number} index - Index of needed frame
|
|
157
|
-
* @return {Frame} - Frame by index in array
|
|
158
|
-
*/
|
|
159
|
-
getFrame(index) {
|
|
160
|
-
if (this._frames.length > index) {
|
|
161
|
-
return this._frames[index]
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
throw new Error('No frames for given index')
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @return {FrameChain}
|
|
169
|
-
*/
|
|
170
|
-
clone() {
|
|
171
|
-
return new FrameChain(this._logger, this)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
exports.FrameChain = FrameChain
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {BrowserNames, UserAgent} = require('@applitools/eyes-common')
|
|
4
|
-
const captureFrameAndPoll = require('../dist/captureFrameAndPoll')
|
|
5
|
-
const captureFrameAndPollForIE = require('../dist/captureFrameAndPollForIE')
|
|
6
|
-
|
|
7
|
-
async function getCaptureDomScript({webDriver, logger}) {
|
|
8
|
-
const userAgent = await webDriver.getUserAgent()
|
|
9
|
-
const isIE = UserAgent.parseUserAgentString(userAgent).getBrowser() === BrowserNames.IE
|
|
10
|
-
logger.log(`using ${isIE ? 'IE' : 'standard'} dom capture`)
|
|
11
|
-
return !isIE ? captureFrameAndPoll : captureFrameAndPollForIE
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = getCaptureDomScript
|
package/lib/hash.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
function hash(str) {
|
|
4
|
-
let hash = 0
|
|
5
|
-
let i, chr
|
|
6
|
-
if (str.length === 0) return hash
|
|
7
|
-
for (i = 0; i < str.length; i++) {
|
|
8
|
-
chr = str.charCodeAt(i)
|
|
9
|
-
hash = (hash << 5) - hash + chr
|
|
10
|
-
hash |= 0
|
|
11
|
-
}
|
|
12
|
-
return hash
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = hash
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ClientFunction} = require('testcafe')
|
|
4
|
-
const {TypeUtils} = require('@applitools/eyes-common')
|
|
5
|
-
const EYES_NAME_SPACE = '__EYES__APPLITOOLS__'
|
|
6
|
-
const MAX_OBJECT_SIZE = 1024 * 1024 * 4.0 // 4 MB
|
|
7
|
-
const {isString} = TypeUtils
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* Split the result to smaller chunks if it is too big.
|
|
11
|
-
* See: https://github.com/DevExpress/testcafe/issues/1110
|
|
12
|
-
*/
|
|
13
|
-
function makeClientFunctionWrapper({
|
|
14
|
-
clientFunctionExecuter = ClientFunction,
|
|
15
|
-
maxObjectSize = MAX_OBJECT_SIZE,
|
|
16
|
-
logger = {log: () => {}},
|
|
17
|
-
window,
|
|
18
|
-
}) {
|
|
19
|
-
return (browserFunction, dependencies = {}) => {
|
|
20
|
-
const getResultMeta = clientFunctionExecuter(
|
|
21
|
-
() => {
|
|
22
|
-
const browserFunctionPromised = browserFunction.then
|
|
23
|
-
? browserFunction
|
|
24
|
-
: () => Promise.resolve(browserFunction())
|
|
25
|
-
return browserFunctionPromised().then((result = {}) => {
|
|
26
|
-
const resultStr = isString(result) ? result : JSON.stringify(result)
|
|
27
|
-
if (!window[EYES_NAME_SPACE]) {
|
|
28
|
-
window[EYES_NAME_SPACE] = {}
|
|
29
|
-
}
|
|
30
|
-
window[EYES_NAME_SPACE].clientFunctionResult = resultStr
|
|
31
|
-
return {size: resultStr.length, isString: isString(result)}
|
|
32
|
-
})
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
dependencies: Object.assign({EYES_NAME_SPACE, browserFunction, isString}, dependencies),
|
|
36
|
-
},
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const getResult = clientFunctionExecuter(
|
|
40
|
-
(start, end) => window[EYES_NAME_SPACE].clientFunctionResult.substring(start, end),
|
|
41
|
-
{dependencies: {EYES_NAME_SPACE}},
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
return async t => {
|
|
45
|
-
const getResultMetaWithT = getResultMeta.with({boundTestRun: t})
|
|
46
|
-
const getResultWithT = getResult.with({boundTestRun: t})
|
|
47
|
-
const {size, isString} = await getResultMetaWithT()
|
|
48
|
-
const splits = Math.ceil(size / maxObjectSize)
|
|
49
|
-
logger.log(`starting to collect ClientFunction result of size ${size}`)
|
|
50
|
-
let result = ''
|
|
51
|
-
for (let i = 0; i < splits; i += 1) {
|
|
52
|
-
const start = i * maxObjectSize
|
|
53
|
-
logger.log(`getting ClientFunction result chunk ${i + 1} of ${splits}`)
|
|
54
|
-
result += await getResultWithT(start, start + maxObjectSize)
|
|
55
|
-
}
|
|
56
|
-
return isString ? result : JSON.parse(result)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.makeClientFunctionWrapper = makeClientFunctionWrapper
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {PositionMemento} = require('@applitools/eyes-sdk-core')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Encapsulates state for {@link CssTranslatePositionProvider} instances.
|
|
7
|
-
*
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
class CssTranslatePositionMemento extends PositionMemento {
|
|
11
|
-
/**
|
|
12
|
-
* @param {String} transforms - The current transforms. The keys are the style keys from which each of the transforms
|
|
13
|
-
* were taken.
|
|
14
|
-
* @param {Location} position
|
|
15
|
-
*/
|
|
16
|
-
constructor(transforms, position) {
|
|
17
|
-
super()
|
|
18
|
-
|
|
19
|
-
this._transforms = transforms
|
|
20
|
-
this._position = position
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @return {String} - The current transforms. The keys are the style keys from which each of the transforms
|
|
25
|
-
* were taken.
|
|
26
|
-
*/
|
|
27
|
-
getTransform() {
|
|
28
|
-
return this._transforms
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @return {Location}
|
|
33
|
-
*/
|
|
34
|
-
getPosition() {
|
|
35
|
-
return this._position
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.CssTranslatePositionMemento = CssTranslatePositionMemento
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ArgumentGuard} = require('@applitools/eyes-common')
|
|
4
|
-
const {PositionProvider} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
const {EyesTestcafeUtils} = require('../EyesTestcafeUtils')
|
|
7
|
-
const makeFixImageMarkPosition = require('./fixImageMarkPosition')
|
|
8
|
-
const {CssTranslatePositionMemento} = require('./CssTranslatePositionMemento')
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A {@link PositionProvider} which is based on CSS translates. This is useful when we want to stitch a page which
|
|
12
|
-
* contains fixed position elements.
|
|
13
|
-
*/
|
|
14
|
-
class CssTranslatePositionProvider extends PositionProvider {
|
|
15
|
-
/**
|
|
16
|
-
* @param {Logger} logger
|
|
17
|
-
* @param {TestcafeExecutor} executor
|
|
18
|
-
* @param {WebElement} scrollRootElement
|
|
19
|
-
*/
|
|
20
|
-
constructor(logger, executor, scrollRootElement) {
|
|
21
|
-
super()
|
|
22
|
-
|
|
23
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
24
|
-
ArgumentGuard.notNull(executor, 'executor')
|
|
25
|
-
ArgumentGuard.notNull(scrollRootElement, 'scrollRootElement')
|
|
26
|
-
|
|
27
|
-
this._logger = logger
|
|
28
|
-
this._executor = executor
|
|
29
|
-
this._scrollRootElement = scrollRootElement
|
|
30
|
-
|
|
31
|
-
/** @type {Location} */
|
|
32
|
-
this._lastSetPosition = undefined
|
|
33
|
-
|
|
34
|
-
this._logger.verbose('creating CssTranslatePositionProvider')
|
|
35
|
-
this._fixImageMarkPosition = makeFixImageMarkPosition({
|
|
36
|
-
executor: this._executor,
|
|
37
|
-
logger: this._logger,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
async getCurrentPosition() {
|
|
45
|
-
this._logger.verbose(`position to return: ${this._lastSetPosition}`)
|
|
46
|
-
return this._lastSetPosition
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @inheritDoc
|
|
51
|
-
*/
|
|
52
|
-
async setPosition(location) {
|
|
53
|
-
ArgumentGuard.notNull(location, 'location')
|
|
54
|
-
this._logger.verbose(`CssTranslatePositionProvider - Setting position to: ${location}`)
|
|
55
|
-
|
|
56
|
-
let translate = `translate(-${location.getX()}px, -${location.getY()}px)`
|
|
57
|
-
if (location.getX() === 0 && location.getY() === 0) {
|
|
58
|
-
translate = ''
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
await this._fixImageMarkPosition(-location.getX(), -location.getY())
|
|
62
|
-
await this._executor.executeScript(
|
|
63
|
-
`arguments[0].style.transform = '${translate}';`,
|
|
64
|
-
this._scrollRootElement,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
this._logger.verbose('Done!')
|
|
68
|
-
this._lastSetPosition = location
|
|
69
|
-
return this._lastSetPosition
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @inheritDoc
|
|
74
|
-
*/
|
|
75
|
-
async getEntireSize() {
|
|
76
|
-
const entireSize = await EyesTestcafeUtils.getEntireElementSize(
|
|
77
|
-
this._executor,
|
|
78
|
-
this._scrollRootElement,
|
|
79
|
-
)
|
|
80
|
-
this._logger.verbose('CssTranslatePositionProvider - Entire size:', entireSize)
|
|
81
|
-
return entireSize
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @inheritDoc
|
|
86
|
-
* @return {Promise<CssTranslatePositionMemento>}
|
|
87
|
-
*/
|
|
88
|
-
async getState() {
|
|
89
|
-
let transforms = await this._executor.executeScript(
|
|
90
|
-
'return arguments[0].style.transform;',
|
|
91
|
-
this._scrollRootElement,
|
|
92
|
-
)
|
|
93
|
-
// TODO
|
|
94
|
-
// maybe we can do something else here ? check, since if later we
|
|
95
|
-
// try to update to this translate we set it to "" as well..
|
|
96
|
-
if (!transforms) {
|
|
97
|
-
transforms = 'translate(0px, 0px)'
|
|
98
|
-
}
|
|
99
|
-
this._logger.verbose('Current transform', transforms)
|
|
100
|
-
return new CssTranslatePositionMemento(transforms, this._lastSetPosition)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// noinspection JSCheckFunctionSignatures
|
|
104
|
-
/**
|
|
105
|
-
* @inheritDoc
|
|
106
|
-
* @param {CssTranslatePositionMemento} state - The initial state of position
|
|
107
|
-
* @return {Promise}
|
|
108
|
-
*/
|
|
109
|
-
async restoreState(state) {
|
|
110
|
-
let transform = state.getTransform()
|
|
111
|
-
if (transform === 'translate(0px, 0px)') {
|
|
112
|
-
transform = ''
|
|
113
|
-
}
|
|
114
|
-
const script = `arguments[0].style.transform = '${transform}';`
|
|
115
|
-
|
|
116
|
-
await this._fixImageMarkPosition(0, 0)
|
|
117
|
-
await this._executor.executeScript(script, this._scrollRootElement)
|
|
118
|
-
this._logger.verbose('Transform (position) restored.')
|
|
119
|
-
this._lastSetPosition = state.getPosition()
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @return {WebElement}
|
|
124
|
-
*/
|
|
125
|
-
getScrolledElement() {
|
|
126
|
-
return this._scrollRootElement
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
exports.CssTranslatePositionProvider = CssTranslatePositionProvider
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {Location} = require('@applitools/eyes-common')
|
|
4
|
-
const {PositionMemento} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Encapsulates state for {@link ElementPositionProvider} instances.
|
|
8
|
-
*
|
|
9
|
-
* @ignore
|
|
10
|
-
*/
|
|
11
|
-
class ElementPositionMemento extends PositionMemento {
|
|
12
|
-
/**
|
|
13
|
-
* @param {Location} position - The current location to be saved.
|
|
14
|
-
*/
|
|
15
|
-
constructor(position) {
|
|
16
|
-
super()
|
|
17
|
-
|
|
18
|
-
this._position = new Location(position)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @return {number}
|
|
23
|
-
*/
|
|
24
|
-
getX() {
|
|
25
|
-
return this._position.getX()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @return {number}
|
|
30
|
-
*/
|
|
31
|
-
getY() {
|
|
32
|
-
return this._position.getY()
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.ElementPositionMemento = ElementPositionMemento
|