1.input标签
众所周知,input标签是可以直接send_keys的,这里也不例外,来看代码示例:
示例网址:http://www.sahitest.com/demo/php/fileUpload.htm
代码:
# -*- coding: utf-8 -*-
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://sahitest.com/demo/php/fileUpload.htm')
upload = driver.find_element_by_id('file')
upload.send_keys('d:\\baidu.py') # send_keys
print upload.get_attribute('value') # check value
driver.quit()
很明显,对于input上传,直接send_keys是最简单的解决方案。