Can't upload file using Selenium with Python. POST POST /session/b90ee4c1-ef51-4cc0-8543-dfd76c7a151d/file did not match a known command

偶尔善良 提交于 2019-12-20 06:28:50

问题


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:


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


来源:https://stackoverflow.com/questions/42754877/cant-upload-file-using-selenium-with-python-post-post-session-b90ee4c1-ef51-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!