Can't upload file using Selenium with Python.

2020-05-03 10:42发布

I am trying to upload a file to this website

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

my_mail = "email@yahoo.com"

driver = webdriver.Firefox("C:\\Users\Daniel\AppData\Local\Programs\Python\Python36-32\Scripts")
driver.get("https://www.ngs.noaa.gov/OPUS/")
assert "OPUS" in driver.title

driver.find_element_by_name("uploadfile").send_keys("C:\\Users\\Daniel\\Desktop\\popo\\uhc30010.15d")

email = driver.find_element_by_name("email_address")
email.send_keys(my_mail)

driver.find_element_by_name("Static").click()

but I am getting this error

selenium.common.exceptions.WebDriverException: Message: POST /session/b90ee4c1-ef51-4cc0-8543-dfd76c7a151d/file did not match a known command

1条回答
SAY GOODBYE
2楼-- · 2020-05-03 11:38

sorry this was inadvertently broken. It will be fixed in the next release:

557a114

As a workaround, you can set the _is_remote property of the webdriver to False after you create it:

driver = webdriver.Firefox()
driver._is_remote = False
查看更多
登录 后发表回答