【问题标题】:Visual testing with Nightwatch-vrt: Test passed, element is captures, but no picture is seen使用 Nightwatch-vrt 进行视觉测试:测试通过,元素被捕获,但看不到图片
【发布时间】:2022-07-06 06:12:23
【问题描述】:

我在我的项目中本地安装了 nightwatch-vrt。 Npm 向我展示了多个我忽略的漏洞。 我创建了一个 nightwatch.vrt.conf.js,内容如下:

const path = require('path');
const baseConfig = require('./nightwatch.conf.js');

const config = {
    ...baseConfig,
    custom_commands_path: ['node_modules/nightwatch-vrt/commands'],
    custom_assertions_path: ['node_modules/nightwatch-vrt/assertions']
};

function generateScreenshotFilePath(nightwatchClient, basePath, fileName) {
    const moduleName = nightwatchClient.currentTest.module,
        testName = nightwatchClient.currentTest.name;
 
    return path.join(process.cwd(), basePath, moduleName, testName, fileName);
};

config.test_settings.default.globals = {
    "visual_regression_settings": {
        "generate_screenshot_path": generateScreenshotFilePath,
        "latest_screenshots_path": "vrt/latest",
        "latest_suffix": "",
        "baseline_screenshots_path": "vrt/baseline",
        "baseline_suffix": "",
        "diff_screenshots_path": "vrt/diff",
        "diff_suffix": "",
        "threshold": 0.5,
        "prompt": false,
        "always_save_diff_screenshot": true
    }
}

module.exports = config;

我的测试(简单,只是为了看看它是否有效)看起来像:

module.exports = {

    tags: ['x'],

    'visual testing':function(browser) {
        browser
            .url('https://www.kraeuter-und-duftpflanzen.de')
            .maximizeWindow()
            .assert.visible('.header-main')
            .pause(1000)
            .assert.screenshotIdenticalToBaseline('.header-main')
            //.saveScreenshot('./tests_output/image.png')
            .end();
    }
}

现在测试通过了,没有断言失败,创建了一个文件夹并且文件被正确命名放置在那里,但是我只能看到一个带有棋盘格图案的字段(如矢量图形中的透明背景),其大小为捕获的大小元素。 在显示这样的测试报告消息之前:

[32644:26476:0414/082519.134:ERROR:device_event_log_impl.cc(214)] [08:25:19.134] 
USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: 
Ein an das System angeschlossenes Gerõt funktioniert nicht. (0x1F)

如果我让 Nightwatch 自己截屏,它会正确显示。 有谁知道错在哪里?

【问题讨论】:

    标签: nightwatch.js nightwatch


    【解决方案1】:

    您解决了这个问题吗?我也面临同样的问题。

    【讨论】:

    • 请不要添加 Me too 作为答案。它实际上并没有提供问题的答案。如果你有一个不同但相关的问题,那么ask它(如果它有助于提供上下文,请参考这个问题)。如果您对这个特定问题感兴趣,您可以upvote 它,留下comment,或者在您有足够的reputation 时开始bounty
    猜你喜欢
    • 2017-09-21
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    • 2010-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多