【问题标题】:Why browser.saveScreen() function does not work in Image Comparison Service of WebdriverIO?为什么 browser.saveScreen() 函数在 WebdriverIO 的图像比较服务中不起作用?
【发布时间】:2021-07-16 13:40:28
【问题描述】:

我尝试创建测试来比较屏幕截图,使用 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() 不能正常工作。 任何建议将不胜感激。

【问题讨论】:

    标签: javascript webdriver-io image-comparison visual-testing


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-11
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      相关资源
      最近更新 更多