npm install wdio-image-comparison-service
const { join } = require('path');
services: [
['chromedriver'],
['image-comparison',
// The options
{
// Some options, see the docs for more
baselineFolder: join(process.cwd(), './tests/'),
formatImageName: '{tag}-{logName}-{width}x{height}',
screenshotPath: join(process.cwd(), '.tmp/'),
savePerInstance: true,
autoSaveBaseline: true,
blockOutStatusBar: true,
blockOutToolBar: true,
ignoreNothing: true // Without this option, it errors out only when mismatch is above 1.23%(by default)
// ... more options
}],
],
describe('Example', () => {
it('should save some screenshots', () => {
browser.url('https://Codemify.com/interview/interview');
// Save a screen
browser.saveScreen('examplePaged', { /* some options */ });
// Save an element
browser.saveElement($('.rightSideBarUL'), 'firstButtonElement', { /* some options */ });
// Save a full page screenshot
browser.saveFullPageScreen('fullPage', { /* some options */ });
// // Save a full page screenshot with all tab executions
browser.saveTabbablePage('save-tabbable', { /* some options, use the same options as for saveFullPageScreen */ });
});
it('should compare successful with a baseline', () => {
browser.url('https://Codemify.com/interview/interview');
// Check a screen
expect(browser.checkScreen('examplePaged', { /* some options */ })).toEqual(0);
// Check an element
expect(browser.checkElement($('.rightSideBarUL'), 'firstButtonElement', { /* some options */ })).toEqual(0);
// Check a full page screenshot
expect(browser.checkFullPageScreen('fullPage', { /* some options */ })).toEqual(0);
// // Check a full page screenshot with all tab executions
expect(browser.checkTabbablePage('check-tabbable', { /* some options, use the same options as for checkFullPageScreen */ })).toEqual(0);
});
});