【问题标题】:How to upload multiple files with Robot Framework如何使用 Robot Framework 上传多个文件
【发布时间】:2018-09-08 17:32:21
【问题描述】:

我目前正在使用 Robot Framework 在浏览器上使用应用程序进行自动化测试。使用选择文件关键字一次上传 1 个文件很容易。但是如何上传多个文件?就我而言,我需要选择该目录中的所有文件并上传它们。

【问题讨论】:

    标签: testing automation automated-tests robotframework


    【解决方案1】:

    对我来说,这个 Python 自定义关键字完成了用\n 分隔文件路径的工作(至少证明它在 Chrome 中有效):

    from robot.libraries.BuiltIn import BuiltIn
    
    class CustomKeywords:
      def choose_files(self, locator, file_paths):
        sl = BuiltIn().get_library_instance('SeleniumLibrary')
        sl.find_element(locator).send_keys(file_paths)
    

    然后可以像这样使用关键字: Choose Files | my_upload_field_locator | ${CURDIR}/file_1.csv \n ${CURDIR}/file_2.csv

    使用一些额外的 Python 可以将其改进为不需要 \n 作为文件路径。

    【讨论】:

      猜你喜欢
      • 2019-11-12
      • 1970-01-01
      • 2018-01-29
      • 1970-01-01
      • 2016-09-08
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 2017-11-08
      相关资源
      最近更新 更多