【发布时间】:2021-11-23 03:17:26
【问题描述】:
这只是一个非常基本的机器人测试用例/脚本。这是从网络导出 .csv 文件。
*** Settings ***
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
${DIR} C:\\Users\\xxxxx\\Reports
*** Test Cases ***
Sample exporting of csv file
empty directory ${DIR}
${prefs} = Create Dictionary download.default_directory=${DIR}
open browser https://xxxxxxxxxxxxxxxxx.com headlesschrome executable_path=${BROWSERDRI} options=add_experimental_option("prefs",${prefs})
input text //*[@id="name"] xxxxx
input password //*[@id="password"] xxxxx
click button //*[@id="button_primary"]
click element //*[@id="content-header"]/div/span[3]/a/div
click element //*[@id="exportDropdown"]/ul/li[3]/a
click link //*[@id="exportCsvColumns_control"]/div/div[1]/div/a[2]
click button //*[@id="exportSubmit"]
sleep 5s
move file oldfilename newfilename
close browser
如您所见,该文件将下载到 C:\Users\xxxxx\Reports。现在,我想重命名文件。所以我只是把“移动文件旧文件名新文件名”,错误是:
C:\Users\xxxxxxx\PycharmProjects\ExportFiles\oldfilename' 不存在。
这就是我的 .robot 文件所在的位置。如何返回 C:\Users\xxxxx\Reports 以便使用“移动文件”更改文件名?或者如果你有更好的建议?目标只是更改下载文件的文件名。请多多包涵,因为我只是在练习机器人。提前谢谢你。
【问题讨论】:
-
如果它告诉你文件不存在,它不存在。请发布实际错误。您发布的错误不是完整的错误,或者它告诉您您的文件名以单引号结尾。
-
嗨 Bryan,是的,它在 C:\Users\xxxxxxx\PycharmProjects\ExportFiles\oldfilename 中不存在,因为它确实在 C:\Users\xxxxx\Reports 中。这就是为什么我问我怎样才能回到 C:\Users\xxxxx\Reports 以便我可以执行“移动文件 oldfilename newfilename”
-
为什么不给它正确的路径呢?无需更改目录。
标签: robotframework