Image 量角器:如何比较整版截图和量角器图像比较

Image 量角器:如何比较整版截图和量角器图像比较,image,protractor,comparison,Image,Protractor,Comparison,我从wswebcreation nl中找到了这个模块,在我的案例中,我发现它非常有趣和有用。然而,我还不太擅长量角器,我在比较整页屏幕时遇到了问题。不过,比较元素图像是可行的,但仍然会引发错误 Config.js onPrepare: function() { // protractor-image-comparison module const protractorImageComparison = require('protractor

我从wswebcreation nl中找到了这个模块,在我的案例中,我发现它非常有趣和有用。然而,我还不太擅长量角器,我在比较整页屏幕时遇到了问题。不过,比较元素图像是可行的,但仍然会引发错误

Config.js

    onPrepare: function() {
            // protractor-image-comparison module
            const protractorImageComparison = require('protractor-image-comparison');
            browser. protractorImageComparison = new protractorImageComparison(
                {
                    autoSaveBaseline: true,
                    baselineFolder: '../baseline/',
                    screenshotPath: '../actual_screenshots/',
                    debug: true,
                    disableCSSAnimation: true,
                    nativeWebScreenshot: true,
                    blockOutStatusBar: true,
                    ignoreColors: true
                }
            );
    ...
    }
规格js

// page objects
var landingPage = require('../landing_page/landing_page.js');

describe('User is on landing page', function() {
it('should see landing page screenshot compared successfully to the baseline', function() {
        // initialize page object
        var landing = new landingPage();

        browser.protractorImageComparison.saveElement(landing.registerButton, 'imageA');

        expect(browser.protractorImageComparison.checkElement(landing.registerButton, 'imageB')).toEqual('imageA');

    });
});
测试完成后,我在所有文件夹中都有元素的截图(基线、实际截图/实际截图和实际截图/差异)

来自控制台的错误:

规范已启动。用户位于登录页上 √ 应该看到注册按钮

##############################################compareOptions={isScreen:false,ignoreAntialiasing:false,IgnoreColor:true, ignoreRectangles:[],ignoreTransparentPixel:false}

# F×应看到登录页截图,与 基线 -预期0等于“imageA”


我自己发现它没有按照我预期的方式工作,因为我不明白expect应该如何工作。因此,与其使用
.toEqual('imageA');
这应该像
.toEqual(0)那样编写
这意味着0%的差异。对于像我这样的noobs来说,文档中有些东西不是很清楚。否则,图像比较会按照预期完美地工作。

当我使用
浏览器时。GradutorImageComparison.saveFullPageScreen('imageA');expect(browser.GradutorImageComparison.checkFullPageScreen('imageB'))。toEqual('imageA'));
然后错误失败:browser.gragratorimagecomparison.saveFullPageScreen不是函数。