为什么我使用selenium上传文件并找不到文件错误?

时间:2017-07-16 08:15:22

标签: python selenium

这是我使用的代码。 我阅读了selenium链接here。并遵循它。

但我得到的错误是这样的:

selenium.common.exceptions.WebDriverException: Message: File not found:
C:/MyPython/DownloadGooglePic/save.png

代码:

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()

url = "http://zhcn.109876543210.com/"

driver.get(url)
# input_field = driver.find_element_by_id("selectfiles")
input_field = driver.find_element_by_css_selector('div#container input[type="file"]')
# input_field.send_keys('save.png')
input_field.send_keys('C:/MyPython/DownloadGooglePic/save.png')
submit_upload_button = driver.find_element_by_css_selector('input#postfiles')
submit_upload_button.click()

wait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.ok>img')))
print("upload done")

CSS选择器就在这里。 enter image description here

0 个答案:

没有答案