Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用appium和WebDrivero拍摄定位器的屏幕截图,然后与其他定位器的屏幕截图进行比较_Appium_Webdriver Io - Fatal编程技术网

如何使用appium和WebDrivero拍摄定位器的屏幕截图,然后与其他定位器的屏幕截图进行比较

如何使用appium和WebDrivero拍摄定位器的屏幕截图,然后与其他定位器的屏幕截图进行比较,appium,webdriver-io,Appium,Webdriver Io,如何使用appium和WebDrivero拍摄定位器的屏幕截图,然后与其他定位器的屏幕截图进行比较(并比较这两幅图像)。我试着看了一本教程,但没有找到任何有用的东西。你可以用webdriver io捕获一个元素的屏幕截图,如下所述 it('should save a screenshot of the browser view', function () { const elem = $('#someElem'); elem.saveScreenshot('./some/path

如何使用appium和WebDrivero拍摄定位器的屏幕截图,然后与其他定位器的屏幕截图进行比较(并比较这两幅图像)。我试着看了一本教程,但没有找到任何有用的东西。你可以用
webdriver io
捕获一个元素的屏幕截图,如下所述

it('should save a screenshot of the browser view', function () {
    const elem = $('#someElem');
    elem.saveScreenshot('./some/path/elemScreenshot.png');
});
您可以在的官方文档中查看有关的更多信息

一旦捕获了这两个元素的屏幕截图,就可以为
WebdriverIO
V5调用可视化回归服务

安装: 使用以下命令作为(dev-)依赖项在本地安装此模块:

npm install --save-dev wdio-image-comparison-service
可以找到有关如何安装WebdriverIO的说明

用法:

describe('Example', () => {
  beforeEach(() => {
     browser.url('https://webdriver.io');
  });



  it('should save some screenshots', () => {

    // Save an element
    browser.saveElement($('#element-id'), 'firstButtonElement', { /* some options*/ });

  });



  it('should compare successful with a baseline', () => {

    // Check an element
    expect(browser.checkElement($('#element-id'), 'firstButtonElement', { /* some options*/ })).toEqual(0);

  });
});
wdio图像比较服务支持NodeJS 8或更高版本

配置:
wdio图像比较服务
是一项服务,因此可以作为正常服务使用。您可以在
wdio.conf.js
文件中使用以下内容进行设置:

const { join } = require('path');

// wdio.conf.js
exports.config = {
    // ...
    // =====
    // Setup
    // =====
    services: [ 
        ['image-comparison', 
        // The options
        {
            // Some options, see the docs for more
            baselineFolder: join(process.cwd(), './tests/sauceLabsBaseline/'),
            formatImageName: '{tag}-{logName}-{width}x{height}',
            screenshotPath: join(process.cwd(), '.tmp/'),
            savePerInstance: true,
            autoSaveBaseline: true,
            blockOutStatusBar: true,
            blockOutToolBar: true,
            // ... more options
        }], 
    ],
    // ...
};
编写测试以比较两个元素的屏幕截图:

describe('Example', () => {
  beforeEach(() => {
     browser.url('https://webdriver.io');
  });



  it('should save some screenshots', () => {

    // Save an element
    browser.saveElement($('#element-id'), 'firstButtonElement', { /* some options*/ });

  });



  it('should compare successful with a baseline', () => {

    // Check an element
    expect(browser.checkElement($('#element-id'), 'firstButtonElement', { /* some options*/ })).toEqual(0);

  });
});

refereec:请检查有关图像比较的所有详细信息

您使用的是哪种语言?@Muzzamil-appium-webdrivero with-javascript请检查解决方案并让我知道。@测试自动化我必须检查图像的部分比较。在底部检查这里,“检查结果”将返回不匹配百分比。所以,您可以对函数中的不匹配百分比和期望百分比应用验证条件。