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

b4qexyjb  于 10个月前  发布在  Windows
关注(0)|答案(1)|浏览(72)

此问题已在此处有答案

How to upload multiple files to a website using Python and Selenium?(1个答案)
16小时前关闭
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\automation\automation\resources\PageObject\testData\uploadFiles\fztcdrSupportedFiles**/sample_bmp.bmp**

ldfqzlk8

ldfqzlk81#

使用 Python 进行文件上传,通过send_keys()发送文件名,需要传递绝对文件路径,如下所示:

uploadElement.send_keys("C:\Users\Suraj\Downloads\automation\automation\resources\PageObject\testData\uploadFiles\fztcdrSupportedFiles\sample_bmp.bmp");

字符串

相关问题