【问题标题】:How can we change the chrome default download directory in Testcafe?我们如何更改 Testcafe 中的 chrome 默认下载目录?
【发布时间】:2022-01-23 10:37:09
【问题描述】:

请提供在Testcafe中设置下载文件路径的步骤。

【问题讨论】:

  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: testing download automated-tests e2e-testing testcafe


【解决方案1】:

如果您需要查找和检查下载的文件,可以使用以下方式:

import fs from 'fs';
import downloadsFolder from 'downloads-folder';

fixture('fixture')
    .page('http://example.com/');

test('test', async t => {
    await t.click('#download');

    const filePath = downloadsFolder() + '/my-file.txt';

    await t.expect(fs.existsSync(filePath)).ok();
});

此外,TestCafe 内部 API 允许您更改下载路径:https://stackoverflow.com/a/65732040/10684943。请注意,不建议使用此方法。使用它需要您自担风险。

【讨论】:

    猜你喜欢
    • 2016-05-28
    • 1970-01-01
    • 2016-07-14
    • 2016-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    相关资源
    最近更新 更多