protractor-image-comparison
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -0,1 +1,11 @@ | ||
# CHANGELOG | ||
<a name="1.6.0"></a> | ||
# [1.6.0](https://github.com/wswebcreation/protractor-image-comparison/compare/v1.5.1...v1.6.0) (2018-03-04) | ||
### Feature | ||
* Enable taking screenshot directly from canvas, see [47](https://github.com/wswebcreation/protractor-image-comparison/pull/47), tnx to [tuomas2](https://github.com/tuomas2) | ||
<a name="1.5.1"></a> | ||
@@ -2,0 +12,0 @@ # [1.5.1](https://github.com/wswebcreation/protractor-image-comparison/compare/v1.5.0...v1.5.1) (2018-01-13) |
@@ -217,2 +217,3 @@ ## Classes | ||
| options.disableCSSAnimation | <code>boolean</code> | enable or disable CSS animation | | ||
| options.canvasScreenshot | <code>boolean</code> | enable or disable taking screenshot directly from canvas (via dataUrl instead of browser.takeScreenshot()). !!This isn't supported in IE11 and Safari 9!! | | ||
@@ -227,2 +228,4 @@ **Example** | ||
browser.protractorImageComparison.saveElement(element(By.id('elementId')), 'imageA', {disableCSSAnimation: true}); | ||
// Take screenshot directly of a canvas element | ||
browser.protractorImageComparison.saveElement(element(By.id('canvasID')), 'imageA', {canvasScreenshot: true}); | ||
``` | ||
@@ -229,0 +232,0 @@ <a name="saveFullPageScreen"></a> |
@@ -22,2 +22,4 @@ # Methods | ||
> You can now also directly take a screenshot of a canvas element by providing `{canvasScreenshot: true}` | ||
Code details and example usage can be found [here](./index.md). | ||
@@ -24,0 +26,0 @@ |
19
index.js
@@ -1023,2 +1023,4 @@ 'use strict'; | ||
* browser.protractorImageComparison.saveElement(element(By.id('elementId')), 'imageA', {disableCSSAnimation: true}); | ||
* // Take screenshot directly of a canvas element | ||
* browser.protractorImageComparison.saveElement(element(By.id('canvasID')), 'imageA', {canvasScreenshot: true}); | ||
* | ||
@@ -1030,5 +1032,7 @@ * @param {Promise} element The ElementFinder that is used to get the position | ||
* @param {boolean} options.disableCSSAnimation enable or disable CSS animation | ||
* @param {boolean} options.canvasScreenshot enable or disable taking screenshot directly from canvas (via dataUrl instead of browser.takeScreenshot()). !!This isn't supported in IE11 and Safari 9!! | ||
* @returns {Promise} The images has been saved when the promise is resolved | ||
* @public | ||
*/ | ||
saveElement(element, tag, options) { | ||
@@ -1043,3 +1047,13 @@ let saveOptions = options || []; | ||
return this._getInstanceData() | ||
.then(() => browser.takeScreenshot()) | ||
.then(() => { | ||
if(saveOptions.canvasScreenshot) { | ||
return element.getWebElement() | ||
.then(elem => browser.executeScript((canvas) => canvas.toDataURL('image/png'), elem)) | ||
.then(dataUrl => dataUrl.split(',')[1]); | ||
} | ||
else { | ||
return browser.takeScreenshot() | ||
} | ||
} | ||
) | ||
.then(screenshot => { | ||
@@ -1049,3 +1063,4 @@ bufferedScreenshot = new Buffer(screenshot, 'base64'); | ||
return this._determineRectangles(element); | ||
if(!saveOptions.canvasScreenshot) | ||
return this._determineRectangles(element); | ||
}) | ||
@@ -1052,0 +1067,0 @@ .then(rectangles => this._saveCroppedScreenshot(bufferedScreenshot, this.actualFolder, rectangles, tag)); |
{ | ||
"name": "protractor-image-comparison", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "npm-module to compare images with protractor", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,4 +16,4 @@ protractor-image-comparison | ||
- save or compare screens / elements against a baseline | ||
- **NEW:** save or compare a fullpage screenshot against a baseline (**desktop AND mobile are now supported**) | ||
- **NEW** automatically create a baseline when no baseline is there | ||
- save or compare a fullpage screenshot against a baseline (**desktop AND mobile are now supported**) | ||
- automatically create a baseline when no baseline is there | ||
- disable css animations by default | ||
@@ -23,7 +23,8 @@ - ignore anti-aliasing differences | ||
- blockout custom regions during comparison (all) | ||
- **NEW** ignore regions by making them transparent in the base image (all) thanks to [tharders](https://github.com/tharders) | ||
- **NEW** parameter to hide / show scrollbars [pnad](https://github.com/pnad) | ||
- ignore regions by making them transparent in the base image (all) thanks to [tharders](https://github.com/tharders) | ||
- parameter to hide / show scrollbars [pnad](https://github.com/pnad) | ||
- increase the element dimenisions screenshots (all) | ||
- provide custom iOS and Android offsets for status-/address-/toolbar (mobile only) | ||
- automatically exclude a statusbar during screencomparison (mobile only) | ||
- **NEW**, taking a screenshot directly from canvas, tnx to [tuomas2](https://github.com/tuomas2), see [here](https://github.com/wswebcreation/protractor-image-comparison/blob/master/docs/index.md#saveelementelement-tag-options--promise). **!!This isn't supported in IE11 and Safari 9!!** | ||
@@ -30,0 +31,0 @@ Comparison is based on [ResembleJS](https://github.com/Huddle/Resemble.js). |
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
801533
1375
93