我在 Windows 操作系统上的 Firefox 浏览器中上传文件时遇到路径问题,我可以在日志中看到 / 而不是 \ [重复]

问题描述 投票:0回答:1

Robot log file

我正在尝试使用 Firefox 浏览器上传文件,但它在 Windows 系统中给我路径错误,而相同的代码在 MAC 系统上运行

如果您看到日志文件错误,而不是可见的“\”正斜杠“/”黑色斜杠,并且它仅发生在 Firefox 浏览器的 Windows 上。

InvalidArgumentException: Message: File not found: C:\Users\Suraj\Downloads\automation\automation\resources\PageObject\testData\uploadFiles\fztcdrSupportedFiles/sample_bmp.bmp Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:187:5 InvalidArgumentError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:378:5 interaction.uploadFiles@chrome://remote/content/marionette/interaction.sys.mjs:543:13**strong text**

InvalidArgumentException:消息:找不到文件:C:\Users\Suraj\Downloads utomation utomation esources\PageObject estData\uploadFiles ztcdrSupportedFiles**/sample_bmp.bmp**

python java selenium-webdriver robotframework geckodriver
1个回答
0
投票

使用Python进行文件上传,通过

send_keys()
发送文件名,您需要传递绝对文件路径,如下所示:

uploadElement.send_keys("C:\Users\Suraj\Downloads\automation\automation\resources\PageObject\testData\uploadFiles\fztcdrSupportedFiles\sample_bmp.bmp");
© www.soinside.com 2019 - 2024. All rights reserved.