这是我使用的代码。 我阅读了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")