【问题标题】:How to change the xml name dynamically after every automation script run如何在每个自动化脚本运行后动态更改 xml 名称
【发布时间】:2019-10-11 17:49:42
【问题描述】:

我在量角器中运行了几个自动化脚本,并且我遇到一种情况,即应用程序每次上传都需要唯一的 xml 文件名,因此通过自动化我如何才能实现这一点,我必须通过更改多次上传相同的文件它的文件名在文件外部和内部。它只允许xml文件。

请提出一些解决方案。

提前致谢。

【问题讨论】:

    标签: javascript automation protractor xml-validation uiveri5


    【解决方案1】:

    您应该能够通过 nodeJS 的fs 模块并根据当前时间附加一个唯一的时间戳来实现这一点。我尚未对此进行测试,但这可能会起作用

    const fs = require('fs');
    const newName = `file_${Date.now()}.xml`
    fs.renameSync('file.xml', newName);
    //Then upload your file however you need to
    

    这将在指定位置创建filename.xml 的副本并将其重命名为filename_1570786998048.xml

    【讨论】:

    • 感谢您的建议,我会尝试这种方法。
    猜你喜欢
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    相关资源
    最近更新 更多