Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eyes.selenium

Package Overview
Dependencies
Maintainers
3
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eyes.selenium - npm Package Compare versions

Comparing version 3.8.0 to 3.8.1

4

package.json
{
"name": "eyes.selenium",
"version": "3.8.0",
"version": "3.8.1",
"description": "Applitools Eyes SDK For Selenium JavaScript WebDriver",

@@ -75,3 +75,3 @@ "keywords": [

},
"gitHead": "9187d7271ee8b54668272841c6e8fdc2dd28bb1f"
"gitHead": "e42e09aff5f2a7dfd167f5c40490729a42b2dcf1"
}

@@ -96,58 +96,26 @@ (function () {

EyesWebDriverScreenshot.prototype.buildScreenshot = function (screenshotType, frameLocationInScreenshot, frameSize) {
var that = this, viewportSize, imageSize;
var that = this;
var positionProvider = new ScrollPositionProvider(this._logger, this._driver, this._promiseFactory);
return this._driver.getDefaultContentViewportSize(false).then(function (vs) {
viewportSize = vs;
imageSize = that._image.getSize();
return positionProvider.getEntireSize();
}).then(function (ppEs) {
// If we're inside a frame, then the frame size is given by the frame
// chain. Otherwise, it's the size of the entire page.
if (!frameSize) {
if (that._frameChain.size() !== 0) {
frameSize = that._frameChain.getCurrentFrameSize();
} else {
// get entire page size might throw an exception for applications
// which don't support Javascript (e.g., Appium). In that case
// we'll use the viewport size as the frame's size.
if (ppEs) {
frameSize = ppEs;
} else {
frameSize = viewportSize;
}
}
}
return positionProvider.getCurrentPosition();
}).then(function (ppCp) {
// Getting the scroll position. For native Appium apps we can't get the scroll position, so we use (0,0)
if (ppCp) {
that._currentFrameScrollPosition = ppCp;
return that._updateScreenshotType(screenshotType, that._image).then(function (screenshotType) {
that._screenshotType = screenshotType;
return that._driver.isMobileDevice();
}).then(function (isMobileDevice) {
if (!isMobileDevice) {
return that._getUpdatedScrollPosition(positionProvider).then(function (sp) {
that._currentFrameScrollPosition = sp;
return that._updateFrameLocationInScreenshot(frameLocationInScreenshot);
}).then(function () {
return that._getFrameSize(positionProvider);
}).then(function (frameSize) {
that._logger.verbose("Calculating frame window...");
that._frameWindow = GeometryUtils.createRegionFromLocationAndSize(that._frameLocationInScreenshot, frameSize);
});
} else {
that._currentFrameScrollPosition = GeometryUtils.createLocation(0, 0);
that._frameLocationInScreenshot = GeometryUtils.createLocation(0, 0);
that._frameWindow = GeometryUtils.createRegionFromLocationAndSize(that._frameLocationInScreenshot, that._image.getSize());
}
if (screenshotType == null) {
if (imageSize.width <= viewportSize.width && imageSize.height <= viewportSize.height) {
screenshotType = ScreenshotType.VIEWPORT;
} else {
screenshotType = ScreenshotType.ENTIRE_FRAME;
}
}
that._screenshotType = screenshotType;
// This is used for frame related calculations.
if (frameLocationInScreenshot == null) {
if (that._frameChain.size() > 0) {
frameLocationInScreenshot = calcFrameLocationInScreenshot(that._logger, that._frameChain, that._screenshotType);
} else {
frameLocationInScreenshot = GeometryUtils.createLocation(0, 0);
}
}
that._frameLocationInScreenshot = frameLocationInScreenshot;
that._logger.verbose("Calculating frame window..");
that._frameWindow = GeometryUtils.createRegionFromLocationAndSize(frameLocationInScreenshot, frameSize);
}).then(function () {
var imageSize = that._image.getSize();
if (GeometryUtils.isRegionsIntersected(that._frameWindow, GeometryUtils.createRegion(0, 0, imageSize.width, imageSize.height))) {

@@ -166,2 +134,76 @@ that._frameWindow = GeometryUtils.intersect(that._frameWindow, GeometryUtils.createRegion(0, 0, imageSize.width, imageSize.height));

/**
* @private
* @param {PositionProvider} positionProvider
* @return {Promise<{width: number, height: number}>}
*/
EyesWebDriverScreenshot.prototype._getFrameSize = function (positionProvider) {
var that = this;
if (this._frameChain.size() !== 0) {
return this._promiseFactory.resolve(this._frameChain.getCurrentFrameSize());
}
return this._driver.isMobileDevice().then(function (isMobileDevice) {
if (isMobileDevice) {
return positionProvider.getEntireSize();
}
return that._driver.getDefaultContentViewportSize(false)
});
};
/**
* @private
* @param {ScreenshotType} screenshotType
* @param {MutableImage} image
* @return {Promise<ScreenshotType>}
*/
EyesWebDriverScreenshot.prototype._updateScreenshotType = function (screenshotType, image) {
var that = this;
if (!screenshotType) {
return that._driver.getEyes().getViewportSize().then(function (viewportSize) {
if (image.getWidth() <= viewportSize.width && image.getHeight() <= viewportSize.height) {
screenshotType = ScreenshotType.VIEWPORT;
} else {
screenshotType = ScreenshotType.ENTIRE_FRAME;
}
return screenshotType;
});
}
return that._promiseFactory.resolve(screenshotType);
};
/**
* @private
* @param {{x: number, y: number}} location
* @return {Promise}
*/
EyesWebDriverScreenshot.prototype._updateFrameLocationInScreenshot = function (location) {
if (!location) {
if (this._frameChain.size() > 0) {
this._frameLocationInScreenshot = calcFrameLocationInScreenshot(this._logger, this._frameChain, this._screenshotType);
} else {
this._frameLocationInScreenshot = GeometryUtils.createLocation(0, 0);
}
} else {
this._frameLocationInScreenshot = location;
}
};
/**
* @private
* @param {PositionProvider} positionProvider
* @return {Promise<{width: number, height: number}>}
*/
EyesWebDriverScreenshot.prototype._getUpdatedScrollPosition = function (positionProvider) {
return positionProvider.getCurrentPosition().then(function (sp) {
if (!sp) {
sp = GeometryUtils.createLocation(0, 0)
}
return sp;
}).catch(function () {
return GeometryUtils.createLocation(0, 0);
});
};
/**
* @return {{left: number, top: number, width: number, height: number}} The region of the frame which is available in the screenshot,

@@ -168,0 +210,0 @@ * in screenshot coordinates.

@@ -36,2 +36,3 @@ (function () {

this._defaultContentViewportSize = null;
this._isMobileDevice = undefined;
}

@@ -77,5 +78,36 @@

EyesWebDriver.prototype.getUserAgent = function () {
return this._driver.executeScript('return navigator.userAgent');
var that = this;
return this.isMobileDevice().then(function (isMobileDevice) {
if (isMobileDevice) return;
return that._driver.executeScript('return navigator.userAgent');
});
};
//noinspection JSUnusedGlobalSymbols
EyesWebDriver.prototype.getCurrentUrl = function () {
var that = this;
return this.isMobileDevice().then(function (isMobileDevice) {
if (isMobileDevice) return;
return that._driver.getCurrentUrl();
});
};
//noinspection JSUnusedGlobalSymbols
/**
* @package
* @return {Promise<boolean>}
*/
EyesWebDriver.prototype.isMobileDevice = function () {
if (this._isMobileDevice !== undefined) {
return this.getPromiseFactory().resolve(this._isMobileDevice)
}
var that = this;
return this._driver.getCapabilities().then(function (capabilities) {
const platformName = capabilities.get('platformName');
that._isMobileDevice = platformName && ['ANDROID', 'IOS'].includes(platformName.toUpperCase());
return that._isMobileDevice;
});
};
//noinspection JSCheckFunctionSignatures

@@ -82,0 +114,0 @@ /**

@@ -13,3 +13,3 @@ (function () {

* @param {Logger} logger A Logger instance.
* @param {FrameChain} other A frame chain from which the current frame chain will be created.
* @param {FrameChain} [other] A frame chain from which the current frame chain will be created.
*/

@@ -16,0 +16,0 @@ function FrameChain(logger, other) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc