首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在WebdriverIO的图片比较服务中browser.saveScreen()函数不起作用?

为什么在WebdriverIO的图片比较服务中browser.saveScreen()函数不起作用?
EN

Stack Overflow用户
提问于 2021-07-16 21:40:29
回答 1查看 114关注 0票数 0

我尝试使用带有图像比较服务的WebdriverIO创建测试来比较屏幕截图。在“同步”模式下,一切正常。但我想使用‘异步’模式,因为‘同步’模式将不再支持(https://webdriver.io/docs/sync-vs-async)。对于'async‘模式,我的测试如下所示:

代码语言:javascript
复制
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中的设置:

代码语言:javascript
复制
  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/’,我得到错误:

代码语言:javascript
复制
[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()不能正常工作。如有任何建议,我们将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-21 21:00:13

我在browser.checkScreen()中添加了await : await expect(await browser.checkScreen('examplePaged',{/* some options */})).toEqual(0)。现在,异步模式下一切正常。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68410039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档