eyes.selenium
Advanced tools
Comparing version 3.8.2 to 3.8.3
{ | ||
"name": "eyes.selenium", | ||
"version": "3.8.2", | ||
"version": "3.8.3", | ||
"description": "Applitools Eyes SDK For Selenium JavaScript WebDriver", | ||
@@ -42,3 +42,2 @@ "keywords": [ | ||
"src/", | ||
"test/", | ||
"typings/" | ||
@@ -49,12 +48,12 @@ ], | ||
"dependencies": { | ||
"eyes.sdk": "^3.8.0", | ||
"eyes.utils": "^3.8.0" | ||
"eyes.sdk": "^3.8.1", | ||
"eyes.utils": "^3.8.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "*", | ||
"chromedriver": "^75.1.0", | ||
"mocha": "^6.1.4", | ||
"chromedriver": "^78.0.0", | ||
"mocha": "^6.2.2", | ||
"protractor": "^5.4.2", | ||
"selenium-webdriver": "^3.6.0", | ||
"typescript": "^3.5.3" | ||
"typescript": "^3.6.4" | ||
}, | ||
@@ -77,3 +76,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "5b641287f140c228e701bff257b5a10f0d6ba6e9" | ||
"gitHead": "590bf0dbd6be7c4481437874cb3cc674850f20f2" | ||
} |
@@ -37,3 +37,3 @@ (function () { | ||
// We only consider scroll of the default content if this is a viewport screenshot. | ||
if (screenshotType == ScreenshotType.VIEWPORT) { | ||
if (screenshotType === ScreenshotType.VIEWPORT) { | ||
var defaultContentScroll = firstFrame.getParentScrollPosition(); | ||
@@ -278,3 +278,3 @@ locationInScreenshot = GeometryUtils.locationOffset(locationInScreenshot, defaultContentScroll); | ||
if (from == to) { | ||
if (from === to) { | ||
return result; | ||
@@ -287,3 +287,3 @@ } | ||
// if it is actually a sub-screenshot of a region). | ||
if (this._frameChain.size() == 0 && this._screenshotType === ScreenshotType.ENTIRE_FRAME) { | ||
if (this._frameChain.size() === 0 && this._screenshotType === ScreenshotType.ENTIRE_FRAME) { | ||
if ((from === CoordinatesType.CONTEXT_RELATIVE | ||
@@ -290,0 +290,0 @@ || from === CoordinatesType.CONTEXT_AS_IS) |
@@ -50,3 +50,9 @@ (function() { | ||
that._logger.verbose("Setting position to:", location); | ||
return EyesSeleniumUtils.translateTo(this._driver, location, this._promiseFactory).then(function () { | ||
var setFakeTransformScript = `document.documentElement.style.transform = 'translate(10px, -${location.y}px)';`; | ||
var setTransformScript = `document.documentElement.style.transform = 'translate(-${location.x}px, -${location.y}px)';`; | ||
return EyesSeleniumUtils.executeScript(that._driver, setFakeTransformScript, that._promiseFactory).then(function () { | ||
return EyesSeleniumUtils.executeScript(that._driver, setTransformScript, that._promiseFactory, 250); | ||
}).then(function () { | ||
that._logger.verbose("Done!"); | ||
@@ -69,9 +75,13 @@ that._lastSetPosition = location; | ||
/** | ||
* @return {Promise<object.<string, string>>} | ||
* @return {Promise<{transform: object, position: object}>} | ||
*/ | ||
CssTranslatePositionProvider.prototype.getState = function () { | ||
var that = this; | ||
return EyesSeleniumUtils.getCurrentTransform(this._driver, this._promiseFactory).then(function (transforms) { | ||
return EyesSeleniumUtils.executeScript(that._driver, 'return document.documentElement.style.transform;', that._promiseFactory).then(function (transforms) { | ||
that._logger.verbose("Current transform", transforms); | ||
return transforms; | ||
return { | ||
transform: transforms, | ||
position: that._lastSetPosition | ||
}; | ||
}); | ||
@@ -81,3 +91,3 @@ }; | ||
/** | ||
* @param {object.<string, string>} state The initial state of position | ||
* @param {{transform: object, position: object}} state The initial state of position | ||
* @return {Promise<void>} | ||
@@ -87,4 +97,9 @@ */ | ||
var that = this; | ||
return EyesSeleniumUtils.setTransforms(this._driver, state, this._promiseFactory).then(function () { | ||
const script = 'var originalTransform = document.documentElement.style.transform;' + | ||
`document.documentElement.style.transform = '${state.transform}';` + | ||
'return originalTransform;'; | ||
return EyesSeleniumUtils.executeScript(this._driver, script, this._promiseFactory).then(function () { | ||
that._logger.verbose("Transform (position) restored."); | ||
that._lastSetPosition = state.position; | ||
}); | ||
@@ -91,0 +106,0 @@ }; |
@@ -111,10 +111,17 @@ (function () { | ||
if (!global.isEyesOverrodeProtractor) { | ||
var originalElementFn = global.element; | ||
var by = global.by; | ||
var element = global.element; | ||
global.element = function (locator) { | ||
return new ElementFinderWrapper(originalElementFn(locator), that._driver, that._logger); | ||
return new ElementFinderWrapper(element(locator), that._driver, that._logger); | ||
}; | ||
global.$ = function (locator) { | ||
return new ElementFinderWrapper(element(by.css(locator)), that._driver, that._logger); | ||
}; | ||
global.element.all = function (locator) { | ||
return new ElementArrayFinderWrapper(originalElementFn.all(locator), that._driver, that._logger); | ||
return new ElementArrayFinderWrapper(element.all(locator), that._driver, that._logger); | ||
}; | ||
global.$$ = function (locator) { | ||
return new ElementArrayFinderWrapper(element.all(by.css(locator)), that._driver, that._logger); | ||
}; | ||
@@ -906,2 +913,3 @@ global.isEyesOverrodeProtractor = true; | ||
exports.Eyes = Eyes; | ||
exports.StitchMode = StitchMode; | ||
}()); |
@@ -44,3 +44,3 @@ (function () { | ||
return promiseFactory.makePromise(function (resolve) { | ||
if (that._coordinatesType == toCoordinatesType) { | ||
if (that._coordinatesType === toCoordinatesType) { | ||
resolve(that._region); | ||
@@ -47,0 +47,0 @@ return; |
@@ -95,8 +95,2 @@ (function () { | ||
/** | ||
* @private | ||
* @type {string[]} | ||
*/ | ||
var JS_TRANSFORM_KEYS = ["transform", "-webkit-transform"]; | ||
/** | ||
* Executes a script using the browser's executeScript function - and optionally waits a timeout. | ||
@@ -109,3 +103,3 @@ * | ||
* let the browser a chance to stabilize (e.g., finish rendering). | ||
* @param {WebElement} element | ||
* @param {WebElement} [element] | ||
* @return {Promise<void>} A promise which resolves to the result of the script's execution on the tab. | ||
@@ -242,71 +236,2 @@ */ | ||
/** | ||
* Get the current transform of page. | ||
* | ||
* @param {WebDriver} browser The driver which will execute the script to get the scroll position. | ||
* @param {PromiseFactory} promiseFactory | ||
* @return {Promise<object.<string, string>>} A promise which resolves to the current transform value. | ||
*/ | ||
EyesSeleniumUtils.getCurrentTransform = function getCurrentTransform(browser, promiseFactory) { | ||
var script = "return { "; | ||
for (var i = 0, l = JS_TRANSFORM_KEYS.length; i < l; i++) { | ||
script += "'" + JS_TRANSFORM_KEYS[i] + "': document.documentElement.style['" + JS_TRANSFORM_KEYS[i] + "'],"; | ||
} | ||
script += " }"; | ||
return EyesSeleniumUtils.executeScript(browser, script, promiseFactory, undefined); | ||
}; | ||
/** | ||
* Sets transforms for document.documentElement according to the given map of style keys and values. | ||
* | ||
* @param {WebDriver} browser The browser to use. | ||
* @param {object.<string, string>} transforms The transforms to set. Keys are used as style keys and values are the values for those styles. | ||
* @param {PromiseFactory} promiseFactory | ||
* @return {Promise<void>} | ||
*/ | ||
EyesSeleniumUtils.setTransforms = function (browser, transforms, promiseFactory) { | ||
var script = ""; | ||
for (var key in transforms) { | ||
if (transforms.hasOwnProperty(key)) { | ||
script += "document.documentElement.style['" + key + "'] = '" + transforms[key] + "';"; | ||
} | ||
} | ||
return EyesSeleniumUtils.executeScript(browser, script, promiseFactory, 250); | ||
}; | ||
/** | ||
* Set the given transform to document.documentElement for all style keys defined in {@link JS_TRANSFORM_KEYS} | ||
* | ||
* @param {WebDriver} browser The driver which will execute the script to set the transform. | ||
* @param {string} transformToSet The transform to set. | ||
* @param {PromiseFactory} promiseFactory | ||
* @return {Promise<void>} A promise which resolves to the previous transform once the updated transform is set. | ||
*/ | ||
EyesSeleniumUtils.setTransform = function setTransform(browser, transformToSet, promiseFactory) { | ||
var transforms = {}; | ||
if (!transformToSet) { | ||
transformToSet = ''; | ||
} | ||
for (var i = 0, l = JS_TRANSFORM_KEYS.length; i < l; i++) { | ||
transforms[JS_TRANSFORM_KEYS[i]] = transformToSet; | ||
} | ||
return EyesSeleniumUtils.setTransforms(browser, transforms, promiseFactory); | ||
}; | ||
/** | ||
* CSS translate the document to a given location. | ||
* | ||
* @param {WebDriver} browser The driver which will execute the script to set the transform. | ||
* @param {{x: number, y: number}} point | ||
* @param {PromiseFactory} promiseFactory | ||
* @return {Promise<void>} A promise which resolves to the previous transform when the scroll is executed. | ||
*/ | ||
EyesSeleniumUtils.translateTo = function translateTo(browser, point, promiseFactory) { | ||
return EyesSeleniumUtils.setTransform(browser, 'translate(-' + point.x + 'px, -' + point.y + 'px)', promiseFactory); | ||
}; | ||
/** | ||
* Scroll to the specified position. | ||
@@ -412,3 +337,3 @@ * | ||
return EyesSeleniumUtils.executeScript(browser, JS_GET_VIEWPORT_SIZE, promiseFactory, undefined).then(function (results) { | ||
if (isNaN(results[0]) || isNaN(results[1])) { | ||
if (Number.isNaN(results[0]) || Number.isNaN(results[1])) { | ||
reject("Can't parse values."); | ||
@@ -415,0 +340,0 @@ } else { |
@@ -54,3 +54,3 @@ (function () { | ||
for (var i = 0; i < lc1; ++i) { | ||
if (c1.getFrames()[i].getId() !== c1.getFrames()[i].getId()) { | ||
if (c1.getFrames()[i].getId() !== c2.getFrames()[i].getId()) { | ||
return false; | ||
@@ -94,3 +94,3 @@ } | ||
FrameChain.prototype.clear = function () { | ||
return this._frames = []; | ||
this._frames = []; | ||
}; | ||
@@ -97,0 +97,0 @@ |
@@ -261,2 +261,7 @@ /* Type definitions for eyes.selenium 3.6.0 */ | ||
/** | ||
* Get the stitch mode. | ||
* @return The currently set StitchMode. | ||
*/ | ||
getStitchMode(): Eyes.StitchMode; | ||
/** | ||
* Sets the wait time between before each screen capture, including between screen parts of a full page screenshot. | ||
@@ -263,0 +268,0 @@ * @param waitBeforeScreenshots The wait time in milliseconds. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
0
248208
24
5022
Updatedeyes.sdk@^3.8.1
Updatedeyes.utils@^3.8.1