我遇到了量角器图像比较,并想对其进行测试。
我基于example of the website进行了有限测试,但出现错误
失败:无法读取未定义的属性'saveFullPageScreen'。
browser.imageComparison
未定义。
奇怪的是我在示例后收到此错误。对量角器的支持有限,所以我在这里询问。
----------------- test.spec.ts --------------
import { browser, } from 'protractor';
import { Urls, DashboardPage } from '../utils';
fdescribe('protractor-image-comparison desktop', () => {
beforeEach(async () => {
await Urls.gotoDashboard();
await DashboardPage.getVPoints();
// await DashboardPage.removeDebugInfo();
});
it('should save some screenshots', async() => {
// Save a full page screens
await .saveFullPageScreen('fullPage', { /* some options*/ });
});
it('should compare successful with a baseline', async() => {
// Check a full page screens
expect(await browser.imageComparison.checkFullPageScreen('fullPage', { /* some options*/ })).toEqual(0);
});
});
-------------- part of jasmine.ts ---------------
plugins: [
{
// The module name
package: 'protractor-image-comparison',
// Some options, see the docs for more
options: {
baselineFolder: join(process.cwd(), './baseline/'),
formatImageName: `{tag}-{logName}-{width}x{height}`,
screenshotPath: join(process.cwd(), '.tmp/'),
savePerInstance: true,
autoSaveBaseline: true,
blockOutToolBar: true,
clearRuntimeFolder: true,
// ... more options
},
},
],
失败:
1) protractor-image-comparison desktop should save some screenshots Message: Failed: Cannot read property 'saveFullPageScreen' of undefined Stack: TypeError: Cannot read property 'saveFullPageScreen' of undefined at Object.<anonymous> (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:119:83) at step (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:75:27) at Object.next (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:24:53) at c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:17:71 at new Promise (<anonymous>) at __awaiter (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:3:12) at UserContext.<anonymous> (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:110:16) at c:\projects\vital10-frontend\node_modules\jasminewd2\index.js:112:25 at new ManagedPromise (c:\projects\vital10-frontend\node_modules\selenium-webdriver\lib\promise.js:1077:7) at ControlFlow.promise (c:\projects\vital10-frontend\node_modules\selenium-webdriver\lib\promise.js:2505:12) From: Task: Run it("should save some screenshots") in control flow at UserContext.<anonymous> (c:\projects\vital10-frontend\node_modules\jasminewd2\index.js:94:19) at c:\projects\vital10-frontend\node_modules\jasminewd2\index.js:64:48 at ControlFlow.emit (c:\projects\vital10-frontend\node_modules\selenium-webdriver\lib\events.js:62:21) at ControlFlow.shutdown_ (c:\projects\vital10-frontend\node_modules\selenium-webdriver\lib\promise.js:2674:10) at c:\projects\vital10-frontend\node_modules\selenium-webdriver\lib\promise.js:2599:53 From asynchronous test: Error at Suite.<anonymous> (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:109:5) at Object.<anonymous> (c:\projects\vital10-frontend\e2e\jasmine\image_compair\test.spec.ts:93:1) at Module._compile (internal/modules/cjs/loader.js:868:30) at Module.m._compile (c:\projects\vital10-frontend\node_modules\ts-node\src\index.ts:392:23) at Module.m._compile (c:\projects\vital10-frontend\node_modules\ts-node\src\index.ts:392:23) at Module._extensions..js (internal/modules/cjs/loader.js:879:10)
答案 0 :(得分:0)
根据文档,您在browser.imageComparison
之前缺少.saveFullPageScreen