繁体   English   中英

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

[英]Why browser.saveScreen() function does not work in Image Comparison Service of WebdriverIO?

我尝试创建测试来比较屏幕截图,使用 WebdriverIO 和图像比较服务。 在“同步”模式下一切正常。 但我想使用“异步”模式,因为不再支持“同步”模式( https://webdriver.io/docs/sync-vs-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() 不能正常工作。 任何建议将不胜感激。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM