@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,88 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ArgumentGuard, Location} = require('@applitools/eyes-common')
|
|
4
|
-
const {PositionProvider} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
const {ElementPositionMemento} = require('./ElementPositionMemento')
|
|
7
|
-
const {EyesWebElement} = require('../wrappers/EyesWebElement')
|
|
8
|
-
|
|
9
|
-
class ElementPositionProvider extends PositionProvider {
|
|
10
|
-
/**
|
|
11
|
-
* @param {Logger} logger
|
|
12
|
-
* @param {EyesWebDriver} driver
|
|
13
|
-
* @param {EyesWebElement} element
|
|
14
|
-
*/
|
|
15
|
-
constructor(logger, driver, element) {
|
|
16
|
-
super()
|
|
17
|
-
|
|
18
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
19
|
-
ArgumentGuard.notNull(driver, 'driver')
|
|
20
|
-
ArgumentGuard.notNull(element, 'element')
|
|
21
|
-
|
|
22
|
-
this._logger = logger
|
|
23
|
-
this._element =
|
|
24
|
-
element instanceof EyesWebElement ? element : new EyesWebElement(logger, driver, element)
|
|
25
|
-
|
|
26
|
-
this._logger.verbose('creating ElementPositionProvider')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
async getCurrentPosition() {
|
|
33
|
-
this._logger.verbose('getCurrentScrollPosition()')
|
|
34
|
-
const location = await this._element.getScrollLocation()
|
|
35
|
-
this._logger.verbose('Current position:', location)
|
|
36
|
-
return location
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
async setPosition(location) {
|
|
43
|
-
this._logger.verbose('Scrolling element to:', location)
|
|
44
|
-
const result = await this._element.scrollTo(location)
|
|
45
|
-
this._logger.verbose('Done scrolling element! result:', result)
|
|
46
|
-
return result
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @inheritDoc
|
|
51
|
-
*/
|
|
52
|
-
async getEntireSize() {
|
|
53
|
-
this._logger.verbose('enter')
|
|
54
|
-
const scrollSize = await this._element.getScrollSize()
|
|
55
|
-
this._logger.verbose('Entire size:', scrollSize)
|
|
56
|
-
return scrollSize
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @inheritDoc
|
|
61
|
-
* @return {Promise<ElementPositionMemento>}
|
|
62
|
-
*/
|
|
63
|
-
async getState() {
|
|
64
|
-
const position = await this.getCurrentPosition()
|
|
65
|
-
return new ElementPositionMemento(position)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// noinspection JSCheckFunctionSignatures
|
|
69
|
-
/**
|
|
70
|
-
* @inheritDoc
|
|
71
|
-
* @param {ElementPositionMemento} state - The initial state of position
|
|
72
|
-
* @return {Promise}
|
|
73
|
-
*/
|
|
74
|
-
async restoreState(state) {
|
|
75
|
-
const newLocation = new Location(state.getX(), state.getY())
|
|
76
|
-
await this.setPosition(newLocation)
|
|
77
|
-
this._logger.verbose('Position restored.')
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @return {WebElement}
|
|
82
|
-
*/
|
|
83
|
-
getScrolledElement() {
|
|
84
|
-
return this._element
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
exports.ElementPositionProvider = ElementPositionProvider
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {Region} = require('@applitools/eyes-common')
|
|
4
|
-
const {RegionPositionCompensation} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
class FirefoxRegionPositionCompensation extends RegionPositionCompensation {
|
|
10
|
-
/**
|
|
11
|
-
* @param {Eyes} eyes
|
|
12
|
-
* @param {Logger} logger
|
|
13
|
-
*/
|
|
14
|
-
constructor(eyes, logger) {
|
|
15
|
-
super()
|
|
16
|
-
|
|
17
|
-
this._eyes = eyes
|
|
18
|
-
this._logger = logger
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
compensateRegionPosition(region, pixelRatio) {
|
|
25
|
-
if (pixelRatio === 1) {
|
|
26
|
-
return region
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const eyesWebDriver = this._eyes.getDriver()
|
|
30
|
-
const frameChain = eyesWebDriver.getFrameChain()
|
|
31
|
-
if (frameChain.size() > 0) {
|
|
32
|
-
return region
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
region = region.offset(0, -Math.ceil(pixelRatio / 2))
|
|
36
|
-
|
|
37
|
-
if (region.getWidth() <= 0 || region.getHeight() <= 0) {
|
|
38
|
-
return Region.EMPTY
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return region
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.FirefoxRegionPositionCompensation = FirefoxRegionPositionCompensation
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Encapsulates rotation data for images.
|
|
5
|
-
*/
|
|
6
|
-
class ImageRotation {
|
|
7
|
-
/**
|
|
8
|
-
* @param {number} rotation - The degrees by which to rotate.
|
|
9
|
-
*/
|
|
10
|
-
constructor(rotation) {
|
|
11
|
-
this._rotation = rotation
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @return {number} - The degrees by which to rotate.
|
|
16
|
-
*/
|
|
17
|
-
getRotation() {
|
|
18
|
-
return this._rotation
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.ImageRotation = ImageRotation
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {CssTranslatePositionProvider} = require('./CssTranslatePositionProvider')
|
|
4
|
-
const {EyesTestcafeUtils} = require('../EyesTestcafeUtils')
|
|
5
|
-
|
|
6
|
-
class OverflowAwareCssTranslatePositionProvider extends CssTranslatePositionProvider {
|
|
7
|
-
/**
|
|
8
|
-
* @inheritDoc
|
|
9
|
-
*/
|
|
10
|
-
async getEntireSize() {
|
|
11
|
-
const result = await EyesTestcafeUtils.getOverflowAwareContentEntireSize(this._executor)
|
|
12
|
-
this._logger.verbose(`OverflowAwareCssTranslatePositionProvider - Entire size: ${result}`)
|
|
13
|
-
return result
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.OverflowAwareCssTranslatePositionProvider = OverflowAwareCssTranslatePositionProvider
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ScrollPositionProvider} = require('./ScrollPositionProvider')
|
|
4
|
-
const {EyesTestcafeUtils} = require('../EyesTestcafeUtils')
|
|
5
|
-
|
|
6
|
-
class OverflowAwareScrollPositionProvider extends ScrollPositionProvider {
|
|
7
|
-
/**
|
|
8
|
-
* @inheritDoc
|
|
9
|
-
*/
|
|
10
|
-
async getEntireSize() {
|
|
11
|
-
const result = await EyesTestcafeUtils.getOverflowAwareContentEntireSize(this._executor)
|
|
12
|
-
this._logger.verbose(`OverflowAwareScrollPositionProvider - Entire size: ${result}`)
|
|
13
|
-
return result
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.OverflowAwareScrollPositionProvider = OverflowAwareScrollPositionProvider
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {BrowserNames} = require('@applitools/eyes-common')
|
|
4
|
-
const {NullRegionPositionCompensation} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
const {FirefoxRegionPositionCompensation} = require('./FirefoxRegionPositionCompensation')
|
|
7
|
-
const {SafariRegionPositionCompensation} = require('./SafariRegionPositionCompensation')
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @ignore
|
|
11
|
-
*/
|
|
12
|
-
class RegionPositionCompensationFactory {
|
|
13
|
-
/**
|
|
14
|
-
* @param {UserAgent} userAgent
|
|
15
|
-
* @param {Eyes} eyes
|
|
16
|
-
* @param {Logger} logger
|
|
17
|
-
* @return {RegionPositionCompensation}
|
|
18
|
-
*/
|
|
19
|
-
static getRegionPositionCompensation(userAgent, eyes, logger) {
|
|
20
|
-
if (userAgent) {
|
|
21
|
-
if (userAgent.getBrowser() === BrowserNames.Firefox) {
|
|
22
|
-
try {
|
|
23
|
-
if (parseInt(userAgent.getBrowserMajorVersion(), 10) >= 48) {
|
|
24
|
-
return new FirefoxRegionPositionCompensation(eyes, logger)
|
|
25
|
-
}
|
|
26
|
-
} catch (ignore) {
|
|
27
|
-
return new NullRegionPositionCompensation()
|
|
28
|
-
}
|
|
29
|
-
} else if (userAgent.getBrowser() === BrowserNames.Safari) {
|
|
30
|
-
return new SafariRegionPositionCompensation()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return new NullRegionPositionCompensation()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.RegionPositionCompensationFactory = RegionPositionCompensationFactory
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {Region} = require('@applitools/eyes-common')
|
|
4
|
-
const {RegionPositionCompensation} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
class SafariRegionPositionCompensation extends RegionPositionCompensation {
|
|
10
|
-
/**
|
|
11
|
-
* @inheritDoc
|
|
12
|
-
*/
|
|
13
|
-
compensateRegionPosition(region, pixelRatio) {
|
|
14
|
-
if (pixelRatio === 1) {
|
|
15
|
-
return region
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (region.getWidth() <= 0 || region.getHeight() <= 0) {
|
|
19
|
-
return Region.EMPTY
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return region.offset(0, Math.ceil(pixelRatio))
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports.SafariRegionPositionCompensation = SafariRegionPositionCompensation
|
|
@@ -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 ScrollPositionProvider} instances.
|
|
8
|
-
*
|
|
9
|
-
* @ignore
|
|
10
|
-
*/
|
|
11
|
-
class ScrollPositionMemento 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.ScrollPositionMemento = ScrollPositionMemento
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {ArgumentGuard, Location, RectangleSize, EyesError} = require('@applitools/eyes-common')
|
|
4
|
-
const {PositionProvider} = require('@applitools/eyes-sdk-core')
|
|
5
|
-
|
|
6
|
-
const {ScrollPositionMemento} = require('./ScrollPositionMemento')
|
|
7
|
-
|
|
8
|
-
class ScrollPositionProvider extends PositionProvider {
|
|
9
|
-
/**
|
|
10
|
-
* @param {Logger} logger
|
|
11
|
-
* @param {EyesJsExecutor} executor
|
|
12
|
-
* @param {WebElement} scrollRootElement
|
|
13
|
-
*/
|
|
14
|
-
constructor(logger, executor, scrollRootElement) {
|
|
15
|
-
super()
|
|
16
|
-
|
|
17
|
-
ArgumentGuard.notNull(logger, 'logger')
|
|
18
|
-
ArgumentGuard.notNull(executor, 'executor')
|
|
19
|
-
ArgumentGuard.notNull(scrollRootElement, 'scrollRootElement')
|
|
20
|
-
|
|
21
|
-
this._logger = logger
|
|
22
|
-
this._executor = executor
|
|
23
|
-
this._scrollRootElement = scrollRootElement
|
|
24
|
-
|
|
25
|
-
this._logger.verbose('creating ScrollPositionProvider')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {EyesJsExecutor} executor
|
|
30
|
-
* @param {WebElement} scrollRootElement
|
|
31
|
-
* @return {Promise<Location>}
|
|
32
|
-
*/
|
|
33
|
-
static async getCurrentPositionStatic(executor, scrollRootElement) {
|
|
34
|
-
const script = 'const el = arguments[0]; return [el.scrollLeft, el.scrollTop];'
|
|
35
|
-
|
|
36
|
-
const result = await executor.executeScript(script, scrollRootElement)
|
|
37
|
-
return new Location(Math.ceil(result[0]) || 0, Math.ceil(result[1]) || 0)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
*/
|
|
43
|
-
async getCurrentPosition() {
|
|
44
|
-
return ScrollPositionProvider.getCurrentPositionStatic(this._executor, this._scrollRootElement)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @inheritDoc
|
|
49
|
-
*/
|
|
50
|
-
async setPosition(location) {
|
|
51
|
-
try {
|
|
52
|
-
this._logger.verbose(`setting position of ${this._scrollRootElement} to ${location}`)
|
|
53
|
-
const script = `
|
|
54
|
-
if (arguments[0] === document.documentElement && window.scrollTo) {
|
|
55
|
-
window.scrollTo(${location.getX()}, ${location.getY()});
|
|
56
|
-
} else {
|
|
57
|
-
arguments[0].scrollLeft=${location.getX()}; arguments[0].scrollTop=${location.getY()};
|
|
58
|
-
}
|
|
59
|
-
return [arguments[0].scrollLeft, arguments[0].scrollTop];
|
|
60
|
-
`
|
|
61
|
-
|
|
62
|
-
const result = await this._executor.executeScript(script, this._scrollRootElement)
|
|
63
|
-
return new Location(Math.ceil(result[0]) || 0, Math.ceil(result[1]) || 0)
|
|
64
|
-
} catch (err) {
|
|
65
|
-
throw new EyesError('Could not get scroll position!', err)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @inheritDoc
|
|
71
|
-
*/
|
|
72
|
-
async getEntireSize() {
|
|
73
|
-
this._logger.verbose('enter')
|
|
74
|
-
|
|
75
|
-
const script =
|
|
76
|
-
'var el = arguments[0]; var width = Math.max(el.clientWidth, el.scrollWidth);' +
|
|
77
|
-
'var height = Math.max(el.clientHeight, el.scrollHeight);' +
|
|
78
|
-
'return [width, height];'
|
|
79
|
-
|
|
80
|
-
const entireSizeStr = await this._executor.executeScript(script, this._scrollRootElement)
|
|
81
|
-
const result = new RectangleSize(
|
|
82
|
-
Math.ceil(entireSizeStr[0]) || 0,
|
|
83
|
-
Math.ceil(entireSizeStr[1]) || 0,
|
|
84
|
-
)
|
|
85
|
-
this._logger.verbose(`ScrollPositionProvider - Entire size: ${result}`)
|
|
86
|
-
return result
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @inheritDoc
|
|
91
|
-
* @return {Promise<ScrollPositionMemento>}
|
|
92
|
-
*/
|
|
93
|
-
async getState() {
|
|
94
|
-
const position = await this.getCurrentPosition()
|
|
95
|
-
return new ScrollPositionMemento(position)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// noinspection JSCheckFunctionSignatures
|
|
99
|
-
/**
|
|
100
|
-
* @inheritDoc
|
|
101
|
-
* @param {ScrollPositionMemento} state - The initial state of position
|
|
102
|
-
* @return {Promise}
|
|
103
|
-
*/
|
|
104
|
-
async restoreState(state) {
|
|
105
|
-
const newPosition = new Location(state.getX(), state.getY())
|
|
106
|
-
await this.setPosition(newPosition)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @override
|
|
111
|
-
* @return {WebElement}
|
|
112
|
-
*/
|
|
113
|
-
getScrolledElement() {
|
|
114
|
-
return this._scrollRootElement
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
exports.ScrollPositionProvider = ScrollPositionProvider
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
function makeFixImageMarkPosition({executor, logger}) {
|
|
4
|
-
return async function(transformLeft, transformTop) {
|
|
5
|
-
const isZeroPosition = transformLeft === 0 && transformTop === 0
|
|
6
|
-
const fixTestcafeMark = !isZeroPosition
|
|
7
|
-
? `
|
|
8
|
-
const pageHeight = document.documentElement.getBoundingClientRect().height
|
|
9
|
-
const styleContent = \`img.screenshot-mark-hammerhead-shadow-ui {
|
|
10
|
-
bottom: calc(\${pageHeight\}px - 100vh + ${transformTop}px) !important;
|
|
11
|
-
top: auto !important;
|
|
12
|
-
left: auto !important;
|
|
13
|
-
height:
|
|
14
|
-
right: calc(5px + ${transformLeft}px) !important;
|
|
15
|
-
}\`
|
|
16
|
-
let style = document.getElementById('applitools-mark-fix')
|
|
17
|
-
if(!style) {
|
|
18
|
-
style = document.createElement('style')
|
|
19
|
-
style.id = 'applitools-mark-fix'
|
|
20
|
-
document.body.appendChild(style);
|
|
21
|
-
}
|
|
22
|
-
style.innerText = styleContent`
|
|
23
|
-
: `
|
|
24
|
-
const style = document.getElementById('applitools-mark-fix')
|
|
25
|
-
style && style.parentNode.removeChild(style)`
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
logger.verbose('fixImageMarkPosition - fixing testacfe mark, isZeroPosition', isZeroPosition)
|
|
29
|
-
await executor.executeScript(fixTestcafeMark)
|
|
30
|
-
} catch (e) {
|
|
31
|
-
logger.verbose('fixImageMarkPosition - failed to fix testcafe mark', e)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = makeFixImageMarkPosition
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {Location} = require('@applitools/eyes-common')
|
|
4
|
-
|
|
5
|
-
const {RegionVisibilityStrategy} = require('./RegionVisibilityStrategy')
|
|
6
|
-
|
|
7
|
-
const VISIBILITY_OFFSET = 100 // Pixels
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @ignore
|
|
11
|
-
*/
|
|
12
|
-
class MoveToRegionVisibilityStrategy extends RegionVisibilityStrategy {
|
|
13
|
-
/**
|
|
14
|
-
* @param {Logger} logger
|
|
15
|
-
*/
|
|
16
|
-
constructor(logger) {
|
|
17
|
-
super()
|
|
18
|
-
|
|
19
|
-
this._logger = logger
|
|
20
|
-
/** @type {PositionMemento} */
|
|
21
|
-
this._originalPosition = undefined
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
async moveToRegion(positionProvider, location) {
|
|
28
|
-
this._logger.verbose('Getting current position state...')
|
|
29
|
-
|
|
30
|
-
this._originalPosition = await positionProvider.getState()
|
|
31
|
-
this._logger.verbose('Done! Setting position...')
|
|
32
|
-
|
|
33
|
-
// We set the location to "almost" the location we were asked. This is because sometimes, moving the browser
|
|
34
|
-
// to the specific pixel where the element begins, causes the element to be slightly out of the viewport.
|
|
35
|
-
let dstX = location.getX() - VISIBILITY_OFFSET
|
|
36
|
-
dstX = dstX < 0 ? 0 : dstX
|
|
37
|
-
let dstY = location.getY() - VISIBILITY_OFFSET
|
|
38
|
-
dstY = dstY < 0 ? 0 : dstY
|
|
39
|
-
|
|
40
|
-
await positionProvider.setPosition(new Location(dstX, dstY))
|
|
41
|
-
this._logger.verbose('Done!')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @inheritDoc
|
|
46
|
-
*/
|
|
47
|
-
async returnToOriginalPosition(positionProvider) {
|
|
48
|
-
this._logger.verbose('Returning to original position...')
|
|
49
|
-
|
|
50
|
-
await positionProvider.restoreState(this._originalPosition)
|
|
51
|
-
this._logger.verbose('Done!')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.MoveToRegionVisibilityStrategy = MoveToRegionVisibilityStrategy
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {RegionVisibilityStrategy} = require('./RegionVisibilityStrategy')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
class NopRegionVisibilityStrategy extends RegionVisibilityStrategy {
|
|
9
|
-
/**
|
|
10
|
-
* @param {Logger} logger
|
|
11
|
-
*/
|
|
12
|
-
constructor(logger) {
|
|
13
|
-
super()
|
|
14
|
-
|
|
15
|
-
this._logger = logger
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @inheritDoc
|
|
20
|
-
*/
|
|
21
|
-
async moveToRegion(positionProvider, location) {
|
|
22
|
-
// eslint-disable-line no-unused-vars
|
|
23
|
-
this._logger.verbose('Ignored (no op).')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
async returnToOriginalPosition(positionProvider) {
|
|
30
|
-
// eslint-disable-line no-unused-vars
|
|
31
|
-
this._logger.verbose('Ignored (no op).')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.NopRegionVisibilityStrategy = NopRegionVisibilityStrategy
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
* @abstract
|
|
8
|
-
*/
|
|
9
|
-
class RegionVisibilityStrategy {
|
|
10
|
-
// noinspection JSMethodCanBeStatic, JSUnusedGlobalSymbols
|
|
11
|
-
/**
|
|
12
|
-
* @param {PositionProvider} positionProvider
|
|
13
|
-
* @param {Location} location
|
|
14
|
-
* @return {Promise}
|
|
15
|
-
*/
|
|
16
|
-
async moveToRegion(positionProvider, location) {
|
|
17
|
-
throw new TypeError('The method is not implemented!')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// noinspection JSMethodCanBeStatic, JSUnusedGlobalSymbols
|
|
21
|
-
/**
|
|
22
|
-
* @param {PositionProvider} positionProvider
|
|
23
|
-
* @return {Promise}
|
|
24
|
-
*/
|
|
25
|
-
async returnToOriginalPosition(positionProvider) {
|
|
26
|
-
throw new TypeError('The method is not implemented!')
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
exports.RegionVisibilityStrategy = RegionVisibilityStrategy
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {makeGetRenderingInfo} = require('@applitools/eyes-sdk-core')
|
|
4
|
-
const {EyesRunner} = require('./EyesRunner')
|
|
5
|
-
const {TestResultsSummary} = require('./TestResultsSummary')
|
|
6
|
-
const {TestResultContainer} = require('./TestResultContainer')
|
|
7
|
-
|
|
8
|
-
class ClassicRunner extends EyesRunner {
|
|
9
|
-
constructor() {
|
|
10
|
-
super()
|
|
11
|
-
|
|
12
|
-
/** @type {TestResults[]} */
|
|
13
|
-
this._allTestResult = []
|
|
14
|
-
this._getRenderingInfo = undefined
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {boolean} [shouldThrowException=true]
|
|
19
|
-
* @return {Promise<TestResultsSummary>}
|
|
20
|
-
*/
|
|
21
|
-
async getAllTestResults(_shouldThrowException = true) {
|
|
22
|
-
// eslint-disable-line no-unused-vars
|
|
23
|
-
const allResults = []
|
|
24
|
-
for (const testResults of this._allTestResult) {
|
|
25
|
-
allResults.push(new TestResultContainer(testResults))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
await this._closeAllBatches()
|
|
29
|
-
return new TestResultsSummary(allResults)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
makeGetRenderingInfo(getRenderingInfo) {
|
|
33
|
-
if (!this._getRenderingInfo) {
|
|
34
|
-
this._getRenderingInfo = makeGetRenderingInfo(getRenderingInfo)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async getRenderingInfoWithCache() {
|
|
39
|
-
if (this._getRenderingInfo) {
|
|
40
|
-
return this._getRenderingInfo()
|
|
41
|
-
} else {
|
|
42
|
-
throw new Error(
|
|
43
|
-
'Eyes runner could not get rendering info since makeGetRenderingInfo was not called before',
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
exports.ClassicRunner = ClassicRunner
|
package/lib/runner/EyesRunner.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
class EyesRunner {
|
|
4
|
-
constructor() {
|
|
5
|
-
/** @type {Eyes[]} */
|
|
6
|
-
this._eyesInstances = []
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// noinspection JSMethodCanBeStatic
|
|
10
|
-
/**
|
|
11
|
-
* @abstract
|
|
12
|
-
* @param {boolean} [shouldThrowException=true]
|
|
13
|
-
* @return {Promise<TestResultsSummary>}
|
|
14
|
-
*/
|
|
15
|
-
async getAllTestResults(shouldThrowException) {
|
|
16
|
-
// eslint-disable-line no-unused-vars
|
|
17
|
-
throw new TypeError('The method is not implemented!')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @protected
|
|
22
|
-
* @return {Promise<void>}
|
|
23
|
-
*/
|
|
24
|
-
async _closeAllBatches() {
|
|
25
|
-
if (this._eyesInstances.length > 0) {
|
|
26
|
-
const promises = []
|
|
27
|
-
const batchIds = new Set()
|
|
28
|
-
for (const eyesInstance of this._eyesInstances) {
|
|
29
|
-
const batchId = eyesInstance.getBatch().getId()
|
|
30
|
-
if (!batchIds.has(batchId)) {
|
|
31
|
-
batchIds.add(batchId)
|
|
32
|
-
promises.push(eyesInstance.closeBatch())
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
await Promise.all(promises)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.EyesRunner = EyesRunner
|