@applitools/eyes-testcafe 2.0.0-beta.9 → 3.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 +540 -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/EyesVisualGrid.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {makeVisualGridClient, takeDomSnapshot} = require('@applitools/visual-grid-client')
|
|
4
|
-
const {
|
|
5
|
-
ArgumentGuard,
|
|
6
|
-
TypeUtils,
|
|
7
|
-
EyesError,
|
|
8
|
-
UserAgent,
|
|
9
|
-
BrowserType,
|
|
10
|
-
} = require('@applitools/eyes-common')
|
|
11
|
-
const {
|
|
12
|
-
CorsIframeHandle,
|
|
13
|
-
CorsIframeHandler,
|
|
14
|
-
IgnoreRegionByRectangle,
|
|
15
|
-
} = require('@applitools/eyes-sdk-core')
|
|
16
|
-
|
|
17
|
-
const {TestResultsSummary} = require('./runner/TestResultsSummary')
|
|
18
|
-
const {VisualGridRunner} = require('./runner/VisualGridRunner')
|
|
19
|
-
const {Eyes} = require('./Eyes')
|
|
20
|
-
|
|
21
|
-
const VERSION = require('../package.json').version
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @ignore
|
|
25
|
-
*/
|
|
26
|
-
class EyesVisualGrid extends Eyes {
|
|
27
|
-
/** @var {Logger} EyesVisualGrid#_logger */
|
|
28
|
-
/** @var {Configuration} EyesVisualGrid#_configuration */
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new (possibly disabled) Eyes instance that interacts with the Eyes Server at the specified url.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} [serverUrl] - The Eyes server URL.
|
|
34
|
-
* @param {boolean} [isDisabled=false] - Set {@code true} to disable Applitools Eyes and use the WebDriver directly.
|
|
35
|
-
* @param {VisualGridRunner} [runner] - Set shared VisualGridRunner if you want to group results.
|
|
36
|
-
*/
|
|
37
|
-
constructor(serverUrl, isDisabled, runner = new VisualGridRunner()) {
|
|
38
|
-
super(serverUrl, isDisabled, runner)
|
|
39
|
-
|
|
40
|
-
this._isVisualGrid = true
|
|
41
|
-
/** @type {UserAgent} */
|
|
42
|
-
this._userAgent = undefined
|
|
43
|
-
|
|
44
|
-
/** @function */ this._checkWindowCommand = undefined
|
|
45
|
-
/** @function */ this._closeCommand = undefined
|
|
46
|
-
/** @function */ this._abortCommand = undefined
|
|
47
|
-
/** @type {Promise} */ this._closePromise = undefined
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// noinspection JSMethodCanBeStatic
|
|
51
|
-
/**
|
|
52
|
-
* @override
|
|
53
|
-
* @protected
|
|
54
|
-
* @return {string} - The base agent id of the SDK.
|
|
55
|
-
*/
|
|
56
|
-
getBaseAgentId() {
|
|
57
|
-
// TODO - change user agent ?
|
|
58
|
-
return `eyes-testcafe-visualgrid/${VERSION}`
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @inheritDoc
|
|
63
|
-
*/
|
|
64
|
-
async open(driver, appName, testName, viewportSize, sessionType) {
|
|
65
|
-
ArgumentGuard.notNull(driver, 'driver')
|
|
66
|
-
|
|
67
|
-
// noinspection NonBlockStatementBodyJS
|
|
68
|
-
if (appName) this._configuration.setAppName(appName)
|
|
69
|
-
// noinspection NonBlockStatementBodyJS
|
|
70
|
-
if (testName) this._configuration.setTestName(testName)
|
|
71
|
-
// noinspection NonBlockStatementBodyJS
|
|
72
|
-
if (viewportSize) this._configuration.setViewportSize(viewportSize)
|
|
73
|
-
// noinspection NonBlockStatementBodyJS
|
|
74
|
-
if (sessionType) this._configuration.setSessionType(sessionType)
|
|
75
|
-
|
|
76
|
-
// noinspection NonBlockStatementBodyJS
|
|
77
|
-
if (this._runner.getConcurrentSessions()) {
|
|
78
|
-
this._configuration.setConcurrentSessions(this._runner.getConcurrentSessions())
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await this._initDriver(driver)
|
|
82
|
-
|
|
83
|
-
const uaString = await this._driver.getUserAgent()
|
|
84
|
-
if (uaString) {
|
|
85
|
-
this._userAgent = UserAgent.parseUserAgentString(uaString, true)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const {openEyes} = makeVisualGridClient({
|
|
89
|
-
logger: this._logger,
|
|
90
|
-
agentId: this.getFullAgentId(),
|
|
91
|
-
apiKey: this._configuration.getApiKey(),
|
|
92
|
-
showLogs: this._configuration.getShowLogs(),
|
|
93
|
-
saveDebugData: this._configuration.getSaveDebugData(),
|
|
94
|
-
proxy: this._configuration.getProxy(),
|
|
95
|
-
serverUrl: this._configuration.getServerUrl(),
|
|
96
|
-
// concurrency: this._configuration.getConcurrentSessions(),
|
|
97
|
-
renderConcurrencyFactor: this._configuration.getConcurrentSessions(),
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
if (this._configuration.getViewportSize()) {
|
|
101
|
-
await this.setViewportSize(this._configuration.getViewportSize())
|
|
102
|
-
|
|
103
|
-
if (this._configuration.getBrowsersInfo().length === 0) {
|
|
104
|
-
this._configuration.addBrowser(
|
|
105
|
-
this._configuration.getViewportSize().getWidth(),
|
|
106
|
-
this._configuration.getViewportSize().getHeight(),
|
|
107
|
-
BrowserType.CHROME,
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const {checkWindow, close, abort} = await openEyes({
|
|
113
|
-
appName: this._configuration.getAppName(),
|
|
114
|
-
testName: this._configuration.getTestName(),
|
|
115
|
-
displayName: this._configuration.getDisplayName(),
|
|
116
|
-
browser: this._configuration.getBrowsersInfo(),
|
|
117
|
-
properties: this._configuration.getProperties(),
|
|
118
|
-
batchSequenceName:
|
|
119
|
-
this._configuration.getBatch() && this._configuration.getBatch().getSequenceName(),
|
|
120
|
-
batchName: this._configuration.getBatch() && this._configuration.getBatch().getName(),
|
|
121
|
-
batchId: this._configuration.getBatch() && this._configuration.getBatch().getId(),
|
|
122
|
-
baselineBranchName: this._configuration.getBaselineBranchName(),
|
|
123
|
-
baselineEnvName: this._configuration.getBaselineEnvName(),
|
|
124
|
-
baselineName: this._configuration.getBaselineEnvName(),
|
|
125
|
-
envName: this._configuration.getEnvironmentName(),
|
|
126
|
-
branchName: this._configuration.getBranchName(),
|
|
127
|
-
saveFailedTests: this._configuration.getSaveFailedTests(),
|
|
128
|
-
saveNewTests: this._configuration.getSaveNewTests(),
|
|
129
|
-
compareWithParentBranch: this._configuration.getCompareWithParentBranch(),
|
|
130
|
-
ignoreBaseline: this._configuration.getIgnoreBaseline(),
|
|
131
|
-
parentBranchName: this._configuration.getParentBranchName(),
|
|
132
|
-
isDisabled: this._configuration.getIsDisabled(),
|
|
133
|
-
matchTimeout: this._configuration.getMatchTimeout(),
|
|
134
|
-
|
|
135
|
-
ignoreCaret: this._configuration.getIgnoreCaret(),
|
|
136
|
-
matchLevel: this._configuration.getMatchLevel(),
|
|
137
|
-
useDom: this._configuration.getUseDom(),
|
|
138
|
-
enablePatterns: this._configuration.getEnablePatterns(),
|
|
139
|
-
ignoreDisplacements: this._configuration.getIgnoreDisplacements(),
|
|
140
|
-
saveDebugData: this._configuration.getSaveDebugData(),
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
this._isOpen = true
|
|
144
|
-
this._checkWindowCommand = checkWindow
|
|
145
|
-
this._closeCommand = async () =>
|
|
146
|
-
close(true).catch(err => {
|
|
147
|
-
if (Array.isArray(err)) {
|
|
148
|
-
return err
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
throw err
|
|
152
|
-
})
|
|
153
|
-
this._abortCommand = async () => abort(true)
|
|
154
|
-
|
|
155
|
-
return this._driver
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @package
|
|
160
|
-
* @param {boolean} [throwEx=true]
|
|
161
|
-
* @return {Promise<TestResultsSummary>}
|
|
162
|
-
*/
|
|
163
|
-
async closeAndReturnResults(throwEx = true) {
|
|
164
|
-
try {
|
|
165
|
-
const resultsPromise = this._closePromise || this._closeCommand()
|
|
166
|
-
const res = await resultsPromise
|
|
167
|
-
const testResultsSummary = new TestResultsSummary(res)
|
|
168
|
-
|
|
169
|
-
if (throwEx === true) {
|
|
170
|
-
for (const result of testResultsSummary.getAllResults()) {
|
|
171
|
-
if (result.getException()) {
|
|
172
|
-
throw result.getException()
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return testResultsSummary
|
|
178
|
-
} finally {
|
|
179
|
-
this._isOpen = false
|
|
180
|
-
this._closePromise = undefined
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @return {Promise}
|
|
186
|
-
*/
|
|
187
|
-
async closeAsync() {
|
|
188
|
-
if (!this._closePromise) {
|
|
189
|
-
this._closePromise = this._closeCommand()
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @param {boolean} [throwEx]
|
|
195
|
-
* @return {Promise<TestResults>}
|
|
196
|
-
*/
|
|
197
|
-
async close(throwEx = true) {
|
|
198
|
-
const results = await this.closeAndReturnResults(throwEx)
|
|
199
|
-
|
|
200
|
-
for (const result of results.getAllResults()) {
|
|
201
|
-
if (result.getException()) {
|
|
202
|
-
return result.getTestResults()
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return results.getAllResults()[0].getTestResults()
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// noinspection JSMethodCanBeStatic
|
|
210
|
-
/**
|
|
211
|
-
* @return {Promise<?TestResults>}
|
|
212
|
-
*/
|
|
213
|
-
async abort() {
|
|
214
|
-
if (typeof this._abortCommand === 'function') {
|
|
215
|
-
if (this._closePromise) {
|
|
216
|
-
this._logger.verbose('Can not abort while closing async, abort added to close promise.')
|
|
217
|
-
return this._closePromise.then(() => this._abortCommand(true))
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return this._abortCommand()
|
|
221
|
-
}
|
|
222
|
-
return null
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* @return {Promise}
|
|
227
|
-
*/
|
|
228
|
-
async abortAsync() {
|
|
229
|
-
this._closePromise = this.abort()
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @inheritDoc
|
|
234
|
-
*/
|
|
235
|
-
async check(name, checkSettings) {
|
|
236
|
-
ArgumentGuard.notNull(checkSettings, 'checkSettings')
|
|
237
|
-
|
|
238
|
-
if (TypeUtils.isNotNull(name)) {
|
|
239
|
-
checkSettings.withName(name)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// check if we need a region of screenshot, add custom tag if by selector (SHOULD BE BEFORE CAPTURING DOM)
|
|
243
|
-
let targetSelector = await checkSettings.getTargetProvider()
|
|
244
|
-
if (targetSelector) {
|
|
245
|
-
targetSelector = await targetSelector.getSelector(this)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// prepare regions, add custom tag if by selector (SHOULD BE BEFORE CAPTURING DOM)
|
|
249
|
-
const ignoreRegions = await this._prepareRegions(checkSettings.getIgnoreRegions())
|
|
250
|
-
|
|
251
|
-
try {
|
|
252
|
-
this._logger.verbose(`Dom extraction starting (${checkSettings.toString()}) $$$$$$$$$$$$`)
|
|
253
|
-
|
|
254
|
-
const pageDomResults = await takeDomSnapshot({
|
|
255
|
-
executeScript: this._driver.executeScript.bind(this._driver),
|
|
256
|
-
browser: this._userAgent.getBrowser(),
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
const {cdt, url: pageUrl, blobs, resourceUrls, frames} = pageDomResults
|
|
260
|
-
|
|
261
|
-
if (this.getCorsIframeHandle() === CorsIframeHandle.BLANK) {
|
|
262
|
-
CorsIframeHandler.blankCorsIframeSrcOfCdt(cdt, frames)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const resourceContents = this._blobsToResourceContents(blobs)
|
|
266
|
-
if (frames && frames.length > 0) {
|
|
267
|
-
for (let i = 0; i < frames.length; i += 1) {
|
|
268
|
-
frames[i].resourceContents = this._blobsToResourceContents(frames[i].blobs)
|
|
269
|
-
delete frames[i].blobs
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
this._logger.verbose(`Dom extracted (${checkSettings.toString()}) $$$$$$$$$$$$`)
|
|
274
|
-
|
|
275
|
-
const source = await this._driver.getCurrentUrl()
|
|
276
|
-
|
|
277
|
-
await this._checkWindowCommand({
|
|
278
|
-
resourceUrls,
|
|
279
|
-
resourceContents,
|
|
280
|
-
frames,
|
|
281
|
-
url: pageUrl,
|
|
282
|
-
cdt,
|
|
283
|
-
tag: checkSettings.getName(),
|
|
284
|
-
sizeMode:
|
|
285
|
-
checkSettings.getSizeMode() === 'viewport' && this.getForceFullPageScreenshot()
|
|
286
|
-
? 'full-page'
|
|
287
|
-
: checkSettings.getSizeMode(),
|
|
288
|
-
selector: targetSelector,
|
|
289
|
-
region: checkSettings.getTargetRegion(),
|
|
290
|
-
scriptHooks: checkSettings.getScriptHooks(),
|
|
291
|
-
ignore: ignoreRegions,
|
|
292
|
-
floating: checkSettings.getFloatingRegions(),
|
|
293
|
-
sendDom: checkSettings.getSendDom() ? checkSettings.getSendDom() : this.getSendDom(),
|
|
294
|
-
matchLevel: checkSettings.getMatchLevel()
|
|
295
|
-
? checkSettings.getMatchLevel()
|
|
296
|
-
: this.getMatchLevel(),
|
|
297
|
-
source,
|
|
298
|
-
})
|
|
299
|
-
} catch (e) {
|
|
300
|
-
throw new EyesError(`Failed to extract DOM from the page: ${e.toString()}`)
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @private
|
|
306
|
-
* @param {{type: string, url: string, value: string}[]} blobs
|
|
307
|
-
* @return {{type: string, url: string, value: Buffer}[]}
|
|
308
|
-
*/
|
|
309
|
-
_blobsToResourceContents(blobs) {
|
|
310
|
-
return blobs.map(({url, type, value}) => ({
|
|
311
|
-
url,
|
|
312
|
-
type,
|
|
313
|
-
value: Buffer.from(value, 'base64'),
|
|
314
|
-
}))
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @private
|
|
319
|
-
* @param {GetRegion[]} regions
|
|
320
|
-
* @return {{type: string, url: string, value: Buffer}[]}
|
|
321
|
-
*/
|
|
322
|
-
async _prepareRegions(regions) {
|
|
323
|
-
if (regions && regions.length > 0) {
|
|
324
|
-
const newRegions = []
|
|
325
|
-
|
|
326
|
-
for (const region of regions) {
|
|
327
|
-
if (region instanceof IgnoreRegionByRectangle) {
|
|
328
|
-
const plainRegions = await region.getRegion(this, undefined)
|
|
329
|
-
plainRegions.forEach(plainRegion => {
|
|
330
|
-
newRegions.push(plainRegion.toJSON())
|
|
331
|
-
})
|
|
332
|
-
} else {
|
|
333
|
-
const selector = await region.getSelector(this)
|
|
334
|
-
newRegions.push({selector})
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return newRegions
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return regions
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
exports.EyesVisualGrid = EyesVisualGrid
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
* @abstract
|
|
8
|
-
*/
|
|
9
|
-
class ImageOrientationHandler {
|
|
10
|
-
// noinspection JSMethodCanBeStatic
|
|
11
|
-
/**
|
|
12
|
-
* @param {IWebDriver} driver
|
|
13
|
-
* @return {Promise<boolean>}
|
|
14
|
-
*/
|
|
15
|
-
async isLandscapeOrientation(driver) {
|
|
16
|
-
throw Error('Method is not implemented!')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// noinspection JSMethodCanBeStatic
|
|
20
|
-
/**
|
|
21
|
-
* @param {Logger} logger
|
|
22
|
-
* @param {IWebDriver} driver
|
|
23
|
-
* @param {MutableImage} image
|
|
24
|
-
* @return {Promise<number>}
|
|
25
|
-
*/
|
|
26
|
-
async tryAutomaticRotation(logger, driver, image) {
|
|
27
|
-
throw Error('Method is not implemented!')
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.ImageOrientationHandler = ImageOrientationHandler
|
package/lib/JavascriptHandler.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
class JavascriptHandler {
|
|
9
|
-
// noinspection JSMethodCanBeStatic
|
|
10
|
-
/**
|
|
11
|
-
* @param {!string} script
|
|
12
|
-
* @param {...object} args
|
|
13
|
-
* @return {Promise}
|
|
14
|
-
*/
|
|
15
|
-
async handle(script, ...args) {
|
|
16
|
-
return null // do nothing
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.JavascriptHandler = JavascriptHandler
|
package/lib/TestCafeExecutor.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {EyesJsExecutor} = require('@applitools/eyes-sdk-core')
|
|
4
|
-
const {TypeUtils} = require('@applitools/eyes-common')
|
|
5
|
-
const isTestcafeSelector = require('./isTestcafeSelector')
|
|
6
|
-
const makeSafeExecuteFunction = require('./safeExecuteFunction')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @ignore
|
|
10
|
-
*/
|
|
11
|
-
class TestCafeExecutor extends EyesJsExecutor {
|
|
12
|
-
/**
|
|
13
|
-
* @param {EyesWebDriver|WebDriver} driver
|
|
14
|
-
*/
|
|
15
|
-
constructor(driver) {
|
|
16
|
-
super()
|
|
17
|
-
this._driver = driver
|
|
18
|
-
this._safeExecuteFunction = makeSafeExecuteFunction(driver)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
executeScript(script, ...args) {
|
|
25
|
-
if (!TypeUtils.isString(script)) {
|
|
26
|
-
return this.executeFunction(script)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const dependencies = {}
|
|
30
|
-
for (let i = 0; i < args.length; i++) {
|
|
31
|
-
// eslint-disable-line no-plusplus
|
|
32
|
-
dependencies[`arg${i}`] = args[i]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const mapSelector =
|
|
36
|
-
args.length === 1 && isTestcafeSelector(args[0])
|
|
37
|
-
? 'arguments[0] = arguments[0] && arguments[0]()'
|
|
38
|
-
: 'void(0)'
|
|
39
|
-
const func = new Function(
|
|
40
|
-
`return (function() {${mapSelector}; ${script}})(${Object.keys(dependencies).join(',')})`,
|
|
41
|
-
) // eslint-disable-line no-new-func
|
|
42
|
-
return this._driver.eval(func, {dependencies})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async executeFunction(func) {
|
|
46
|
-
return this._safeExecuteFunction(func)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @inheritDoc
|
|
51
|
-
*/
|
|
52
|
-
sleep(_millis) {
|
|
53
|
-
throw new Error('sleep not implemented in test cafe')
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
exports.TestCafeExecutor = TestCafeExecutor
|