Skip to content

Instantly share code, notes, and snippets.

@klamping
Last active November 13, 2015 19:58
Show Gist options
  • Select an option

  • Save klamping/bd2303f3431028d457f9 to your computer and use it in GitHub Desktop.

Select an option

Save klamping/bd2303f3431028d457f9 to your computer and use it in GitHub Desktop.
WebdriverCSS Assertion Util
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