我尝试使用带有图像比较服务的WebdriverIO创建测试来比较屏幕截图。在“同步”模式下,一切正常。但我想使用‘异步’模式,因为‘同步’模式将不再支持(https://webdriver.io/docs/sync-vs-async)。对于'async‘模式,我的测试如下所示:
describe('Example', () => {
it('should save some screenshots', async () => {
await browser.url('https://Codemify.com/interview/interview')
// Save a screen
await browser.saveScreen('examplePaged', {
/* some options */
})
})
it('should compare successful with a baseline', async () => {
await browser.url('https://Codemify.com/interview/interview')
// Check a screen
await expect(
browser.checkScreen('examplePaged', {
/* some options */
})
).toEqual(0)
})
})Wdio.conf.js中的设置:
services: [
['chromedriver'],
[
'image-comparison',
{
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,
},
],
],在上面的示例中,创建了文件夹'.tmp‘,但没有创建基线文件夹'./tests/’,我得到错误:
[chrome 91.0.4472.124 windows #0-0] expect(received).toEqual(expected) // deep equality
Expected: 0
Received: {}
[chrome 91.0.4472.124 windows #0-0] Error: expect(received).toEqual(expected) // deep equality我不明白哪里出了问题..。假设函数browser.saveScreen()不能正常工作。如有任何建议,我们将不胜感激。
发布于 2021-07-21 21:00:13
我在browser.checkScreen()中添加了await : await expect(await browser.checkScreen('examplePaged',{/* some options */})).toEqual(0)。现在,异步模式下一切正常。
https://stackoverflow.com/questions/68410039
复制相似问题