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

protractor-image-comparison

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protractor-image-comparison - npm Package Compare versions

Comparing version 3.1.0-beta.1 to 3.1.0

108

build/protractor.image.compare.js

@@ -74,2 +74,5 @@ "use strict";

_a.instanceData = _b;
return [4, optionElementsToWebElements(saveElementOptions)];
case 3:
saveElementOptions = _e.sent();
_c = webdriver_image_comparison_1.saveElement;

@@ -83,3 +86,3 @@ _d = [{

return [4, element.getWebElement()];
case 3: return [2, _c.apply(void 0, _d.concat([_e.sent(),
case 4: return [2, _c.apply(void 0, _d.concat([_e.sent(),
tag,

@@ -110,2 +113,5 @@ {

_a.instanceData = _b;
return [4, optionElementsToWebElements(saveScreenOptions)];
case 3:
saveScreenOptions = _c.sent();
return [2, webdriver_image_comparison_1.saveScreen({

@@ -125,5 +131,5 @@ executor: protractor_1.browser.executeScript,

return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:

@@ -135,13 +141,22 @@ _a = protractor_1.browser;

case 1:
_b = (_c.sent());
_c.label = 2;
_b = (_d.sent());
_d.label = 2;
case 2:
_a.instanceData = _b;
return [2, webdriver_image_comparison_1.saveFullPageScreen({
executor: protractor_1.browser.executeScript,
screenShot: protractor_1.browser.takeScreenshot
}, protractor_1.browser.instanceData, this.folders, tag, {
wic: this.defaultOptions,
method: saveFullPageScreenOptions,
})];
return [4, optionElementsToWebElements(saveFullPageScreenOptions)];
case 3:
saveFullPageScreenOptions = _d.sent();
if (!saveFullPageScreenOptions.hideAfterFirstScroll) return [3, 5];
_c = saveFullPageScreenOptions;
return [4, getWebElements(saveFullPageScreenOptions.hideAfterFirstScroll)];
case 4:
_c.hideAfterFirstScroll = _d.sent();
_d.label = 5;
case 5: return [2, webdriver_image_comparison_1.saveFullPageScreen({
executor: protractor_1.browser.executeScript,
screenShot: protractor_1.browser.takeScreenshot
}, protractor_1.browser.instanceData, this.folders, tag, {
wic: this.defaultOptions,
method: saveFullPageScreenOptions,
})];
}

@@ -167,2 +182,5 @@ });

_a.instanceData = _b;
return [4, optionElementsToWebElements(checkElementOptions)];
case 3:
checkElementOptions = _e.sent();
_c = webdriver_image_comparison_1.checkElement;

@@ -176,3 +194,3 @@ _d = [{

return [4, element.getWebElement()];
case 3: return [2, _c.apply(void 0, _d.concat([_e.sent(),
case 4: return [2, _c.apply(void 0, _d.concat([_e.sent(),
tag,

@@ -203,2 +221,5 @@ {

_a.instanceData = _b;
return [4, optionElementsToWebElements(checkScreenOptions)];
case 3:
checkScreenOptions = _c.sent();
return [2, webdriver_image_comparison_1.checkScreen({

@@ -231,2 +252,5 @@ executor: protractor_1.browser.executeScript,

_a.instanceData = _b;
return [4, optionElementsToWebElements(checkFullPageOptions)];
case 3:
checkFullPageOptions = _c.sent();
return [2, webdriver_image_comparison_1.checkFullPageScreen({

@@ -272,2 +296,58 @@ executor: protractor_1.browser.executeScript,

}
function optionElementsToWebElements(options) {
return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
if (!options.hideElements) return [3, 2];
_a = options;
return [4, getWebElements(options.hideElements)];
case 1:
_a.hideElements = _d.sent();
_d.label = 2;
case 2:
if (!options.removeElements) return [3, 4];
_b = options;
return [4, getWebElements(options.removeElements)];
case 3:
_b.removeElements = _d.sent();
_d.label = 4;
case 4:
if (!options.hideAfterFirstScroll) return [3, 6];
_c = options;
return [4, getWebElements(options.hideAfterFirstScroll)];
case 5:
_c.hideAfterFirstScroll = _d.sent();
_d.label = 6;
case 6: return [2, options];
}
});
});
}
function getWebElements(elements) {
return __awaiter(this, void 0, void 0, function () {
var i, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
i = 0;
_c.label = 1;
case 1:
if (!(i < elements.length)) return [3, 4];
_a = elements;
_b = i;
return [4, elements[i].getWebElement()];
case 2:
_a[_b] =
(_c.sent());
_c.label = 3;
case 3:
i++;
return [3, 1];
case 4: return [2, elements];
}
});
});
}
//# sourceMappingURL=protractor.image.compare.js.map

@@ -7,2 +7,3 @@ # Things that changed in V3

- `nativeWebScreenshot` has been removed from the options. This can only be added/determined from the capabilities
- `ignoreTransparentPixel` has been removed from the options.
- `androidOffsets` and `iosOffsets` have been removed from the options. They are now set for a lot of iOS and Android versions in the [`webdriver-image-comparison constants.ts`](https://github.com/wswebcreation/webdriver-image-comparison/blob/master/lib/helpers/constants.ts)

@@ -9,0 +10,0 @@ - dropped support for Firefox 47

@@ -12,5 +12,6 @@ import {browser, ElementFinder} from 'protractor';

} from 'webdriver-image-comparison';
import {SaveFullPageMethodOptions} from 'webdriver-image-comparison/build/commands/fullPage.interfaces';
import {SaveScreenMethodOptions} from 'webdriver-image-comparison/build/commands/screen.interfaces';
import {SaveElementMethodOptions} from 'webdriver-image-comparison/build/commands/element.interfaces';
// @TODO: refactor the options, the default options should only be used later on
export default class ProtractorImageComparison extends BaseClass {

@@ -24,5 +25,7 @@ constructor(options: ClassOptions) {

*/
async saveElement(element: ElementFinder, tag: string, saveElementOptions = {}) {
async saveElement(element: ElementFinder, tag: string, saveElementOptions: SaveElementMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
saveElementOptions = await optionElementsToWebElements(saveElementOptions);
return saveElement(

@@ -47,5 +50,7 @@ {

*/
async saveScreen(tag: string, saveScreenOptions = {}) {
async saveScreen(tag: string, saveScreenOptions: SaveScreenMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
saveScreenOptions = await optionElementsToWebElements(saveScreenOptions);
return saveScreen(

@@ -69,5 +74,11 @@ {

*/
async saveFullPageScreen(tag: string, saveFullPageScreenOptions = {}) {
async saveFullPageScreen(tag: string, saveFullPageScreenOptions: SaveFullPageMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
saveFullPageScreenOptions = await optionElementsToWebElements(saveFullPageScreenOptions);
if (saveFullPageScreenOptions.hideAfterFirstScroll) {
saveFullPageScreenOptions.hideAfterFirstScroll = await getWebElements(saveFullPageScreenOptions.hideAfterFirstScroll);
}
return saveFullPageScreen(

@@ -91,5 +102,7 @@ {

*/
async checkElement(element: ElementFinder, tag: string, checkElementOptions = {}) {
async checkElement(element: ElementFinder, tag: string, checkElementOptions: SaveElementMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
checkElementOptions = await optionElementsToWebElements(checkElementOptions);
return checkElement(

@@ -114,5 +127,7 @@ {

*/
async checkScreen(tag: string, checkScreenOptions = {}) {
async checkScreen(tag: string, checkScreenOptions: SaveScreenMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
checkScreenOptions = await optionElementsToWebElements(checkScreenOptions);
return checkScreen(

@@ -136,5 +151,7 @@ {

*/
async checkFullPageScreen(tag: string, checkFullPageOptions = {}) {
async checkFullPageScreen(tag: string, checkFullPageOptions: SaveFullPageMethodOptions = {}) {
browser.instanceData = browser.instanceData || await getInstanceData();
checkFullPageOptions = await optionElementsToWebElements(checkFullPageOptions);
return checkFullPageScreen(

@@ -188,3 +205,34 @@ {

platformName,
};
}
/**
* Transform all `hideElements`, `removeElements` and `hideAfterFirstScroll`-elements to WebElements
*/
async function optionElementsToWebElements(options: SaveFullPageMethodOptions) {
if (options.hideElements) {
options.hideElements = await getWebElements(options.hideElements);
}
if (options.removeElements) {
options.removeElements = await getWebElements(options.removeElements);
}
if (options.hideAfterFirstScroll) {
options.hideAfterFirstScroll = await getWebElements(options.hideAfterFirstScroll);
}
return options;
}
/**
* Get all the web elements
*/
async function getWebElements(elements: HTMLElement[]) {
for (let i = 0; i < elements.length; i++) {
elements[i] =
<HTMLElement><unknown>await (<ElementFinder><unknown>elements[i]).getWebElement();
}
return elements;
}

25

package.json
{
"name": "protractor-image-comparison",
"version": "3.1.0-beta.1",
"version": "3.1.0",
"description": "npm-module to compare images with protractor",

@@ -14,2 +14,3 @@ "main": "./build/index.js",

"precompile": "npm run clean",
"prepublish": "npm run compile",
"compile": "tsc",

@@ -40,21 +41,25 @@ "lint": "tslint -p tsconfig.json",

"dependencies": {
"webdriver-image-comparison": "^0.1.0"
"webdriver-image-comparison": "^0.4.2"
},
"devDependencies": {
"@types/fs-extra": "^5.0.4",
"@types/jasmine": "^3.3.1",
"@types/node": "^10.12.15",
"@types/fs-extra": "^5.0.5",
"@types/jasmine": "^3.3.10",
"@types/node": "^10.14.1",
"awesome-typescript-loader": "^5.2.1",
"fs-extra": "^7.0.1",
"husky": "^1.2.1",
"husky": "^1.3.1",
"jasmine": "^3.3.1",
"jasmine-spec-reporter": "^4.2.1",
"jasmine-ts": "^0.3.0",
"protractor": "^5.4.1",
"rimraf": "^2.6.2",
"protractor": "^5.4.2",
"rimraf": "^2.6.3",
"source-map-loader": "^0.2.4",
"ts-node": "^7.0.1",
"typescript": "^3.2.2",
"validate-commit-msg": "^2.14.0"
"tslint": "^5.12.0",
"tslint-eslint-rules": "^5.4.0",
"tslint-jasmine-rules": "^1.5.1",
"typescript": "^3.3.3333",
"validate-commit-msg": "^2.14.0",
"vrsource-tslint-rules": "^6.0.0"
}
}

@@ -10,2 +10,3 @@ protractor-image-comparison

> **NOTE:** V3 is out, please read the [releases](https://github.com/wswebcreation/protractor-image-comparison/releases) for all the (breaking)changes

@@ -20,2 +21,3 @@ ## What can it do?

- blockout custom regions and even automatically exclude a status and or tool bars (mobile only) during a comparison
- hide / remove elements during comparison like for example stickyheaders (**NEW**)
- increase the element dimensions screenshots

@@ -180,2 +182,3 @@ - use different comparison methods

## TODO:
- [ ] (re)write OUTPUT.md with new images
- [ ] iOS Safari on iPads can have multiple tabs, so the address bar is bigger making the cutout go wrong
- [ ] create a new website

@@ -5,3 +5,4 @@ {

"no-duplicate-variable": true,
"no-jasmine-focus": true,
"no-focused-tests": true,
"no-disabled-tests": true,
"no-var-keyword": true,

@@ -12,2 +13,5 @@ "semicolon": [true],

},
"extends": [
"tslint-jasmine-rules"
],
"rulesDirectory": [

@@ -14,0 +18,0 @@ "node_modules/vrsource-tslint-rules/rules",

Sorry, the diff of this file is not supported yet

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