【发布时间】:2020-09-30 09:12:38
【问题描述】:
当我使用此代码时,它会在 Selenium 中使用 Python 上传文件时出错,谁能帮我解决这个问题?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver=webdriver.Chrome(executable_path="C:\\Users\Archi\PycharmProject\chrome driver\chromedriver")
driver.get("https://www.freshersworld.com/user/register")
driver.implicitly_wait(10)
upload="C://Users/Archi/Downloads/resume testing/Resume testing"
driver.find_element_by_id("file-upload").send_keys("upload")
错误:
selenium.common.exceptions.InvalidArgumentException:消息:无效 参数:找不到文件:上传
即使我也从这种方式检查过,然后也显示错误。
C:/Users/Archi/Downloads/resume testing/Resume testingC:\Users\Archi\Downloads\resume testing/Resume testingC:\\Users\Archi\Downloads\resume testing/Resume testing
【问题讨论】:
-
看起来你有
send_keys("upload"),而你应该有send_keys(upload)而不带引号。 -
感谢您的纠正,但是当我删除引号时,我也会收到错误 selenium.common.exceptions.InvalidArgumentException:消息:无效参数:找不到文件:
-
先生,我认为我使用了错误的斜杠 / ,\ 我应该使用哪个。我从各个方面检查.. 谢谢
标签: python selenium selenium-webdriver file-upload sendkeys