Last active
November 13, 2015 19:58
-
-
Save klamping/bd2303f3431028d457f9 to your computer and use it in GitHub Desktop.
WebdriverCSS Assertion Util
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var expect = require("chai").expect; | |
| var _ = require("lodash"); | |
| var checkMismatch = function(err, res) { | |
| expect(err).to.not.exist; | |
| _.forOwn(res, function(elementShots) { | |
| elementShots.forEach(function(shot) { | |
| expect(shot.isWithinMisMatchTolerance).to.equal(true, "'" + shot.properties.name + "' visual " + shot.message); | |
| }); | |
| }); | |
| }; | |
| /** | |
| * WebdriverCSS command with screenshot mismatch assertion. | |
| * Call it in the exact same manner as you call WebdriverCSS, apart from the assertion function | |
| * | |
| * @param {string} name - Name of screenshots | |
| * @param {boolean} selectors - element information to capture | |
| * @example | |
| * browser.compareScreen("toolbar", { | |
| * name: "toolbar", | |
| * elem: ".toolbar" | |
| * }) | |
| */ | |
| browser.addCommand("compareScreen", function(name, selectors) { | |
| return this.webdrivercss(name, selectors, checkMismatch); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment